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

Author Topic: [SOLVED] Visual Studio 2017 and SFML 2.5.0  (Read 21161 times)

0 Members and 1 Guest are viewing this topic.

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
[SOLVED] Visual Studio 2017 and SFML 2.5.0
« on: May 20, 2018, 05:18:59 am »
I installed Visual Studio 2017 and downloaded SFML Visual C++ 15 (2017) - 32-bit package.
I do not know if they are compatible, but as I did not find the updated SFML package for Visual Studio 2017, I downloaded this one myself.
I configured it according to the video

... because the https://www.sfml-dev.org/tutorials/2.5/start-vc.php tutorial was not clear about using the files with "-d" end and was not working.
But I used the example code on this page and when compiling I get the errors:
Code: [Select]
1>ConsoleApplication2.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>ConsoleApplication2.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)

My question is whether these errors have to do with some mismatch between the installed versions or if the problem is another.
I wanted to avoid the ordeal that is installing SFML manually.
« Last Edit: May 29, 2018, 11:55:32 pm by rogeriodec »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Visual Studio 2017 and SFML
« Reply #1 on: May 20, 2018, 07:57:07 am »
Did you define SFML_STATIC yet link SFML dynamically?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Visual Studio 2017 and SFML
« Reply #2 on: May 21, 2018, 12:35:32 am »
Attached some screenshots.

Is something missing?
« Last Edit: May 21, 2018, 12:47:41 am by rogeriodec »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #3 on: May 21, 2018, 12:49:05 am »
As suspected, you defined SFML_STATIC, yet you're linking SFML dynamically.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #4 on: May 21, 2018, 01:01:36 am »
Thanks, but could you be clearer?
I do not know what to do. What should I correct exactly?

Gamachara

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • My game dev blog
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #5 on: May 21, 2018, 05:11:22 am »
The SFML_STATIC is here. SFML_STATIC tells Visual Studio you should have resources for the static version. You're not linking statically, you're linking dynamically and have the dynamic resources available. Get rid of SFML_STATIC.

Make sure you do this for all build configurations.
« Last Edit: October 31, 2019, 09:53:34 am by Gamachara »

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #6 on: May 21, 2018, 05:28:13 am »
Thanks, now the build does not generate any more error, but when running the program it requires that I copy all the DLLs from C:\ SFML-2.5.0\bin to the folder of my compiled .exe (ConsoleApplication2\Debug).
I did not want to ever have to do this.
How can I generate an .exe without ever having to copy the dlls to the project folder?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #7 on: May 21, 2018, 08:55:59 am »
https://www.sfml-dev.org/tutorials/2.5/start-vc.php
Quote
If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.

billarhos

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #8 on: May 21, 2018, 10:04:49 am »
In windows system you can gather all sfml dlls (and not only), debug and release in one folder and add this path folder in "environment variables" into "system properties" in User "Path".

For instance "D:\ThirdParty\dlls"

Then visual studio automatically detects this path and no longer have to add those dlls in release or debug folder.

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #9 on: May 21, 2018, 06:40:52 pm »
Thank you. Now I understand what the static and dynamic library is.
But the tutorial https://www.sfml-dev.org/tutorials/2.5/start-vc.php talks about the static dlls, the link available for download https://www.sfml-dev.org/files/SFML-2.5.0-windows-vc15-32-bit.zip brings only dynamic libraries.
Is not this contradictory? Should not the static DLLs be included together?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #10 on: May 21, 2018, 07:35:34 pm »
But the tutorial https://www.sfml-dev.org/tutorials/2.5/start-vc.php talks about the static dlls
The tutorial doesn't talk about static dlls, because that's not a thing.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #11 on: May 21, 2018, 08:50:46 pm »
The tutorial doesn't talk about static dlls, because that's not a thing.

From https://www.sfml-dev.org/tutorials/2.5/start-vc.php:
Quote
If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.

I do not want to argue, I just want to solve the problem. The file provided does not have the static DLLs. How to solve this?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #12 on: May 21, 2018, 11:09:05 pm »
Well it's written right there and it doesn't mention anything with static DLLs.
There isn't much more I can do to help you with reading the text, but let me try...

Quote
If you want to get rid of these DLLs [meaning you don't want to use DLLs] and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release. [meaning if you want to link SFML statically, you need to link against the .lib files that have the -s suffix]
In this case[meaning IF and only IF you're linking SFML statically], you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.

So if you want to solve the problem, then do what I have by now pointed out for the third time, do not add SFML_STATIC to your project file if you're not linking statically, which you aren't based on your screenshots.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c0d3r9

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #13 on: May 21, 2018, 11:16:46 pm »
And my two cents.
@rogeriodec
There exists no static DLL´s.
DLL´s are dynamical loaded.
The other "static DLL" that you mean are libraries.And DLL´s are libraries too.
static libraries are included in your app.
DLL´s are seperate libraries wich you provide with your app.

It´s your choice what you use.
Take only one way.

And i must say, because i´m a non pro c++ coder especially with sfml, all infos are on this website.
I build sfml every time from sources with cmake and vs/mingw and i do this never before.
All infos are there.

@eXpl0it3r: a simple thx

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Visual Studio 2017 and SFML 2.5.0
« Reply #14 on: May 24, 2018, 10:32:37 am »
So if you want to solve the problem, then do what I have by now pointed out for the third time, do not add SFML_STATIC to your project file if you're not linking statically, which you aren't based on your screenshots.

that doesn't solve his problem at all

he specifically states he doesn't want to have to move dlls into the exe folder

he WANTS to link statically and he doesn't know which "things" to include in the project

you're getting hung up on the phrase "static dlls"  when its obvious he doesn't know the correct terminology

@rogeriodec
when it says this
"If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix:"

its not saying "if you want to get rid of these dynamic DLLS ... you must link to the static version of the dlls"

its saying "if you want to get rid of the DLLs completely then use the static libs"

sfml-window-s.lib
sfml-system-s.lib

but you'll also have to link to
opengl32.lib
freetype.lib

and other stuff as listed in the chart





 

anything