Jump to content
  • Advertisement
Sign in to follow this  
justcolorado

CPP, SFML Tutorials newbie question

This topic is 2446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 launch a window tutorial. 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: "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. " I wasn't sure how to accomplish "link with SFML_MAIN static library" 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)

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 ==========


#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;
}

Share this post


Link to post
Share on other sites
Advertisement
Your handling of error messages should not be binary. It's a message 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

SFML Tutorial


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
Thank you all!

Loading the library fixed the problem. (Hurray, I can open a window now)
I will try it out on VS2010 with the steps you suggested.
And those configuration steps were very useful.


Thanks! :rolleyes:

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!