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

Author Topic: Unable to compile a SFML project [Visual Studio C++ Express]  (Read 10560 times)

0 Members and 1 Guest are viewing this topic.

Brukmoon

  • Newbie
  • *
  • Posts: 6
    • View Profile
Unable to compile a SFML project [Visual Studio C++ Express]
« on: September 15, 2012, 12:14:43 pm »
Greetings.

I am having issues compiling a C++ SFML project using Visual Studio 2010 Express Edition. This is my first time using the SFML library.
I have followed the tutorial on how to set up SFML on VS. (http://www.sfml-dev.org/tutorials/2.0/start-vc.php)
I am using SFML 2.0.
The library seem to be added, the compiler does not show any compile errors, only two linking errors.
This is the output that the compiler shows when I compile the project [release]:
Code: [Select]
1>------ Build started: Project: SFtest, Configuration: Release Win32 ------
1>  main.cpp
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>c:\users\brukmoon\documents\visual studio 2010\Projects\SFtest\Release\SFtest.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I would appreciate any help. Thank you in advance.

Sincerely,
Brukmoon

Brukmoon

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #1 on: September 15, 2012, 12:22:10 pm »
I have fixed it, I am sorry for wasting your bandwidth. I just had to add -s postfix after the libs names, because I have set the SFML_STATIC preprocessor directive.
But, I am getting one simple warning:
Code: [Select]
1>------ Build started: Project: SFtest, Configuration: Release Win32 ------
1>  main.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>  Generating code
1>  Finished generating code
1>  SFtest.vcxproj -> c:\users\brukmoon\documents\visual studio 2010\Projects\SFtest\Release\SFtest.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
how to fix it?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #2 on: September 15, 2012, 12:40:41 pm »
It's a warning that can be ignored for mostly all cases, but if you want it gone, you'll hace to forbid all the diffrent runtime libraries but without the one you're using. (Project->Settings->Linker->Input)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #3 on: September 15, 2012, 12:42:59 pm »
You might be mixing debug and release .libs.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #4 on: September 15, 2012, 12:49:58 pm »
You might be mixing debug and release .libs.
Sure he might do quite a few things, but it's not directly connected to the warning. ;)

That doesn't say it's okay to mix debug and release, don't mix them! :)
« Last Edit: September 15, 2012, 12:56:56 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #5 on: September 15, 2012, 12:53:18 pm »
I get that warning if I mix release sfml with debug box2d.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Unable to compile a SFML project [Visual Studio C++ Express]
« Reply #6 on: September 15, 2012, 01:01:21 pm »
I get that warning if I mix release sfml with debug box2d.
That's quite possible and it even might show when mixing debug and release with just SFML, because there are diffrent debug and release runtime libraries and if you link them statically the symbols get into the binary and when then called from the application VS sees diffrent symbols from different runtime libraries and throws a warning. Thus one should always use the same runtime libraries for all the different parts one is using in its code.

There was once a more detailed explanation and something about the linking flag /Zi or so that would remove those incompatibility. The warning with SFML even when SFML and your application are using the same runtime library comes from some external libraries afaik, but I might be wrong with this.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/