Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Issue with static linking in MSVC 2012  (Read 3398 times)

0 Members and 1 Guest are viewing this topic.

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Issue with static linking in MSVC 2012
« on: July 19, 2013, 05:43:34 am »
I've been looking through threads for a few hours now trying to find a solution to my problem, but nothing I'm finding appears to be my issue.

Anyways, I'm using MS Visual Studio 2012 with SFML 2.0 and I am trying to statically link the libraries. The errors I am getting are:

Code: [Select]
Error 1 error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::locale const &)" (??0String@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVlocale@3@@Z) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 2 error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 3 error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::create(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 4 error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::close(void)" (?close@Window@sf@@QAEXXZ) referenced in function "void __cdecl getEvents(void)" (?getEvents@@YAXXZ) N:\Projects\C++\RTS\RTS\main.obj RTS
Error 5 error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::isOpen(void)const " (?isOpen@Window@sf@@QBE_NXZ) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 6 error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function "void __cdecl getEvents(void)" (?getEvents@@YAXXZ) N:\Projects\C++\RTS\RTS\main.obj RTS
Error 7 error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(void)" (??0RenderWindow@sf@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'app''(void)" (??__Eapp@@YAXXZ) N:\Projects\C++\RTS\RTS\main.obj RTS
Error 8 error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'app''(void)" (??__Fapp@@YAXXZ) N:\Projects\C++\RTS\RTS\main.obj RTS
Error 9 error LNK2019: unresolved external symbol "void __cdecl getInputs(void)" (?getInputs@@YAXXZ) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 10 error LNK2019: unresolved external symbol "void __cdecl tick(void)" (?tick@@YAXXZ) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 11 error LNK2019: unresolved external symbol "void __cdecl updateScreen(void)" (?updateScreen@@YAXXZ) referenced in function _main N:\Projects\C++\RTS\RTS\main.obj RTS
Error 12 error LNK1120: 11 unresolved externals N:\Projects\C++\RTS\Debug\RTS.exe RTS

Also, some of my output I got during compilation:

Code: [Select]
1>  Unused libraries:
1>    N:\Projects\C++\RTS\RTS\libs\SFML\sfml-graphics-s-d.lib
1>    N:\Projects\C++\RTS\RTS\libs\SFML\sfml-window-s-d.lib
1>    N:\Projects\C++\RTS\RTS\libs\SFML\sfml-system-s-d.lib
1> 
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::locale const &)" (??0String@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVlocale@3@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::create(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::close(void)" (?close@Window@sf@@QAEXXZ) referenced in function "void __cdecl getEvents(void)" (?getEvents@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::isOpen(void)const " (?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function "void __cdecl getEvents(void)" (?getEvents@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(void)" (??0RenderWindow@sf@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'app''(void)" (??__Eapp@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'app''(void)" (??__Fapp@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl getInputs(void)" (?getInputs@@YAXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl tick(void)" (?tick@@YAXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl updateScreen(void)" (?updateScreen@@YAXXZ) referenced in function _main
1>N:\Projects\C++\RTS\Debug\RTS.exe : fatal error LNK1120: 11 unresolved externals

I had a problem before of the linker not finding the .lib files, but after fixing that, I am certain it is finding them. I have them set in Linker>Input>Additional Dependencies as *-s-d.lib and I also have SFML_STATIC set in C/C++>Preprocessor>Preprocessor Definitions. Furthermore, I've seen some sources saying to set C/C++>Code Generation>Runtime Library to Multi-threaded Debug (/MDd).

The only thing I have not done is set up everything for Release, but I don't think that should affect me as long as I'm working in Debug mode. The libraries I am using are sfml-system-s-d.lib, sfml-windows-s-d.lib, and sfml-graphics-s-d.lib.

I've been working with SFML for a few years now, but I constantly get these linker errors and can never solve them. Obviously I'm missing something. Any help or insights would be greatly appreciated.
I issa Cat Person =^w^=

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Issue with static linking in MSVC 2012
« Reply #1 on: July 19, 2013, 10:03:52 am »
What other settings have you been tweaking with?`
Because you're not only getting unresolved symbol errors for SFML code, but also for your own code. Have you made sure that all your files are added to the project, especially the .cpp files that implement getInputs, tick and updateScreen?
The next thing that's rather strange is that your linker seems to ignore the SFML libraries ("unused libraries"). I've never had such an error, thus I must assume, you've been changing a few other options...

If you don't find the problem yourself, you should post just the project file, so we can check the settings ourselves.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Issue with static linking in MSVC 2012
« Reply #2 on: July 19, 2013, 05:15:39 pm »
It's possible I've changed something I shouldn't have. I'm not too familiar with many of the options.

All the files were added correctly to the project, and all my current functions are implemented in main.cpp, so it shouldn't be that. The output from my code was the linker. I set it to verbose so it outputs everything. My code is compiling fine, it's just linking improperly.

I've attached the project file.
I issa Cat Person =^w^=

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Issue with static linking in MSVC 2012
« Reply #3 on: July 19, 2013, 06:45:10 pm »
I didn't go over every single setting, but what I've seen, is that you're not specifying where to find the SFML headers.
Take a close look at the VS tutorial again.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Scipi

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Issue with static linking in MSVC 2012
« Reply #4 on: July 19, 2013, 08:07:54 pm »
How would it compile if it couldn't find the headers?

I don't think that could be it since I put it in the compiler include folder. But just in case, I set the include directory in the settings to the SFML headers and I get the same result.
I issa Cat Person =^w^=

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Issue with static linking in MSVC 2012
« Reply #5 on: July 19, 2013, 08:35:48 pm »
I don't know.
At best you go and setup the project newly following 1:1 the tutorial. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything