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

Author Topic: Having a hard time trying to get SFML to work with Visual Studio 2017  (Read 3018 times)

0 Members and 2 Guests are viewing this topic.

Grime

  • Newbie
  • *
  • Posts: 13
    • View Profile
I don't know where I'm going wrong. I'm using Visual Studio 2017.

I did exactly as told in https://www.sfml-dev.org/tutorials/2.5/start-vc.php
I even tried watching some Youtube videos but they all instructed to do the same thing.

I ran the code from the page and got errors like so:
LNK2019   unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)"..

and many errors like that.

I want to get SFML to work on build mode.

Under additional include libraries, I put the right path, I am able to include SFML without any errors.
I'm sure I added the right path for additional library directories as well.

Under Additional Dependencies I have:
sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-audio-s-d.lib
sfml-network-s-d.lib
sfml-system-s-d.lib
%(AdditionalDependencies)


I've been trying to do all kinds of random stuff to get SFML to work. I just don't get it.. Where have I gone wrong??

Also what is the 'bin' folder for? Are we never going to use it?


FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Having a hard time trying to get SFML to work with Visual Studio 2017
« Reply #1 on: February 09, 2019, 03:27:26 pm »
Did you not define SFML_STATIC? In bin you have dlls, which you don't need except for openal32.dll which is always dll due to licensing covering it. You also need to link all dependencies yourself if you link SFML statically.
Back to C++ gamedev with SFML in May 2023

Grime

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Having a hard time trying to get SFML to work with Visual Studio 2017
« Reply #2 on: February 09, 2019, 04:57:29 pm »
Yes I hadn't put that preprocessor. Okay quite honestly I don't know the difference between static dynamic and whatever.

Let's say I want to use dynamic for now. I didn't put the preprocesor.
I'm still on debug.

I changed the libraries to:
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib

But I get this error while trying to run the program in the tutorial.

I get a series of message boxes titled 'System Error' saying following:
"The code execution cannot be processed because sfml-graphics-d-2.dill was not found. Reinstalling the program may fix this problem".

But why wasn't it found? And where is it?

Along with that sfml-system-d-2.dll, sfml-window-d-2.dl were not found either.

By the way is bin accessed by one of the library or header files? So would that mean that I should not keep the bin file in a separate file?

Also I'm building for debug Win32 and building on debug x86.


FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Having a hard time trying to get SFML to work with Visual Studio 2017
« Reply #3 on: February 09, 2019, 05:02:14 pm »
If you like dynamically you need to put the corresponding dlls from bin near your exe itself. If you link statically you need to define that macro and link all the dependencies yourself (there's a table in the tutorial) too. No matter what kind of linking you use, if you use audio then openal will be a dll (due to licensing).
Back to C++ gamedev with SFML in May 2023

Grime

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Having a hard time trying to get SFML to work with Visual Studio 2017
« Reply #4 on: February 09, 2019, 05:32:40 pm »
Okay here's what I did (to any Googlers). I defined SFML_STATIC in pre-processor directives. Then I pasted all the dependencies from the website. I added a -d to every one of them.

Some of them didn't have a -d version so I had to painfully identify those files.
My dependencies now:
sfml-graphics-s-d.lib    
sfml-window-s-d.lib
sfml-system-s-d.lib
opengl32.lib
freetype.lib
sfml-window-s-d.lib    
winmm.lib
gdi32.lib
sfml-audio-s-d.lib    
openal32.lib
flac.lib
vorbisenc.lib
vorbisfile.lib
vorbis.lib
ogg.lib
sfml-network-s-d.lib    
ws2_32.lib
sfml-system-s-d.lib    
%(AdditionalDependencies)

It works. Thanks a lot FRex.

So I need to add bin to my library directory if I want to use openal/audio?

Lastly in your opinion, which is better dynamic or static and why?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Having a hard time trying to get SFML to work with Visual Studio 2017
« Reply #5 on: February 09, 2019, 06:16:05 pm »
No, you need to copy (Ctrl-C, Ctrl-V) the dlls from bin near your exe.

Because of the license openal that SFML uses is under, SFML makes it always be a dll (even if you like audio statically).

Static vs. dynamic linking is broad topic and both have upsides and downsides.
Back to C++ gamedev with SFML in May 2023

 

anything