Sign in to follow this  
justcolorado

CPP, SFML Tutorials newbie question

Recommended Posts

Hello all,

I am new here. My programming skills are not that great but am one of those that prefers to go the C++ route. At the advice of one of the posts I found somewhere in this forum I installed the SFML libraries and started the tutorials. I was enjoying learning it and everything worked fine until I got to the [url="http://www.sfml-dev.org/tutorials/1.6/window-window.php"]launch a window tutorial[/url]. I put the code in and got a bunch of error messages (see below):
I am not sure what I did wrong. In the tutorial they mentioned this: [u]"Under Windows operating systems, you may have created a "Windows Application" project, especially if don't want the console to show up. In such case, to avoid replacing main by WinMain, you can link with SFML_Main static library and keep a standard and portable main entry point. "[/u][i] [/i]I wasn't sure how to accomplish [u]"link with SFML_MAIN static library"[/u] and that may be the source of the error messages, but I am new to this so really not sure. If anybody knows how I can get this to work so I can go on with the tutorials, I would really appreciate the help.

Thank you!:rolleyes:

(I also posted the full source below)

[code]1>------ Build started: Project: SFML-tutorials, Configuration: Debug Win32 ------
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>C:\Users\colorado\Documents\Visual Studio 2008\Projects\SFML-tutorials\Debug\SFML-tutorials.exe : fatal error LNK1120: 4 unresolved externals
1>Build log was saved at "file://c:\Users\colorado\Documents\Visual Studio 2008\Projects\SFML-tutorials\SFML-tutorials\Debug\BuildLog.htm"
1>SFML-tutorials - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/code]

[code]#include <SFML/Window.hpp>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

// Start main loop
bool Running = true;
while (Running)
{
App.Display();
}
//system ("pause");
return EXIT_SUCCESS;
} [/code]

Share this post


Link to post
Share on other sites
Your handling of error messages should not be binary. It's a [i]message[/i] so read it. If you can't understand the message, Google and find out what they are saying. Don't just mentally flail on the presence of any error message.

> unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main

It can't find the implementation of the various Window functions. Which would mean you didn't link the sfml window library.

Share this post


Link to post
Share on other sites
The SFML tutorial has a step by step setup guide for Visual Studio.
Make sure you go through all the steps

[url="http://www.sfml-dev.org/tutorials/1.6/start-vc.php"]SFML Tutorial[/url]


PS.
From Visual Studio 2010 and forward all these settings is found under the project settings, not the Tools menu as the tutorial says

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this