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

Author Topic: Static linking problem  (Read 13283 times)

0 Members and 2 Guests are viewing this topic.

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #15 on: March 13, 2017, 05:45:04 pm »
Ok now certainly i have good compiled and installed SFML but when i try to compile my own program, i get error: LNK2038   mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in animation.obj   client

When i changed Runtime Library in Debug to Multi-threaded Debug i dont have this error but when i try to open the compiled exe i get error system "Application stopped working"
« Last Edit: March 13, 2017, 05:53:17 pm by Sebox »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #16 on: March 13, 2017, 06:40:20 pm »
Quote
next i marked the SFML_USE_STATIC_STD_LIBS
Don't do that ;)
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #17 on: March 13, 2017, 06:52:30 pm »
Are you sure? If i dont marked this i dont have lib with suffix -s so i can't static link.  :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #18 on: March 14, 2017, 06:30:11 am »
Please read the documentation carefully. This one is a totally different thing. The option you need to care about is BUILD_SHARED_LIBS.
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #19 on: March 14, 2017, 12:47:15 pm »
I unmarked BUILD_SHARED_LIBS and marked SFML_USE_STATIC_STD_LIBS, so i have lib with -s suffix. When i only marked BUILD_SHARED_LIBS i have dynamically libs so without -s. So how i can add this to visual studio ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Static linking problem
« Reply #20 on: March 14, 2017, 12:58:47 pm »
You have to uncheck BUILD_SHARED_LIBS and uncheck SFML_USE_STATIC_STD_LIBS. Read the SFML CMake tutorial to understand what each option does.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #21 on: March 14, 2017, 04:53:33 pm »
I did what u spoken and i have same problem "...Application stopped working..."

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Static linking problem
« Reply #22 on: March 14, 2017, 05:01:20 pm »
SFML hasn't been tested with VS 2017 yet, so there maybe a chance that Microsoft changed something that breaks SFML. However it may also just be a misconfiguration on your end somehow.

I'll look into building SFML with VS 2017 this evening myself.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #23 on: March 14, 2017, 05:51:08 pm »
I turned on debugging and i get error in mutex, so i find in google that sf::RenderWindow can no't be a global variables, i get this in the main() and all is good. Thank you very much for help i think i would do this with super documentation but my main problem is english thats why the lucid tutorial dont help me much. :) :) :)

Intrestingly why its work in dynamic libraries and it makes problem in static hmm :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Static linking problem
« Reply #24 on: March 14, 2017, 06:28:42 pm »
Yes, don't initialize any SFML resources in a global scope. I'd even suggest to not use any global variables at all. There are always better designs, the most simple one being to wrap things into a class and just use the main() function to initialize the class.

I also just quickly built SFML with VS 2017 and everything works fine. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #25 on: March 15, 2017, 08:38:21 pm »
As i wrote all is good but what i have to do if can build static libraries of Visual Studio like "msvcrt140d.dll" ??
When i change runtime library to Multi-Threaded Debug i get error type: LNK2038   mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in animation.obj client

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Static linking problem
« Reply #26 on: March 15, 2017, 10:02:06 pm »
As explained in the CMake tutorial, if you want to link the runtime library statically, you check SFML_USE_STATIC_STD_LIBS and switch your project to /MT and /MTd.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything