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

Author Topic: Static linking problem  (Read 11317 times)

0 Members and 1 Guest are viewing this topic.

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Static linking problem
« on: March 11, 2017, 10:23:59 am »
Hello

I try to static link my game and i get error.
I add SFML_STATIC to preprocessor.
In Release:
(click to show/hide)
In Debug:
(click to show/hide)

And when i run compile all is good but when i try to open my game i get error: "Program game.exe stopped working" when i use debug i get error in line when code is:
 RenderWindow window(VideoMode::getDesktopMode(), "Game", Style::Default, sett);
And the error is "Unhandled exception at the Location 0x77A2FF33 (Ntdll.dll)"
I use Visual Studio 2017, and i download package Visual C++ 14 (2015) - 32-bit
I really dont know where are problem.

sjaustirni

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: Static linking problem
« Reply #1 on: March 11, 2017, 10:48:53 am »
Quote from: SFML downloads
The compiler versions have to match 100%!

which basically means that you need to compile SFML on your own. thankfully, with VS 2017 it's easy these days.
  • Just download the source code, open the folder in VS2017
  • in the menu hit CMake->Generate cache (if it's not done automatically)
  • Then right click on CMakeLists.txt -> Build -> All
  • Check what is the folder where it has compiled and then just point VS with your own project opened to the right folder.
  • Tadah, enjoy!
BTW, While we're at it, make sure that if you compile SFML for 32-bit, that you compile your project for 32-bit as well. The same goes for Debug/Release versions.
« Last Edit: March 11, 2017, 10:52:53 am by sjaustirni »

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #2 on: March 11, 2017, 10:59:38 am »
Thank you for your answer, i add path for compile my own SFML(libs and include) and when i try co compile i get error
"LNK1104 cannot open file 'sfml-window-s-d.lib' client"
« Last Edit: March 11, 2017, 12:00:10 pm by Sebox »

sjaustirni

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: Static linking problem
« Reply #3 on: March 11, 2017, 12:34:43 pm »
This means that you point to a wrong folder, or that VS has no access to it. Check it.

Also, what compiler and linking chain do you use? The MSVC one, or CMake?

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #4 on: March 11, 2017, 12:47:17 pm »
I use CMake. I have 3 folders:


I use path to install:

include and lib. But in lib i only have:

so where can i should find files with suffix -s ??

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #5 on: March 11, 2017, 01:30:29 pm »
Look at the CMake tutorial, it explains all the options that you can change when you configure your SFML build -- including the one to build static libraries.
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #6 on: March 11, 2017, 02:14:33 pm »
Now i have error: "cannot open file freetype.lib"


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #7 on: March 11, 2017, 08:19:59 pm »
Where? When you do what?
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #8 on: March 11, 2017, 08:23:42 pm »
In compilator, when i try to compile program

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #9 on: March 12, 2017, 06:18:52 pm »
If you correctly installed SFML after building it, freetype.lib should be in the same directory as the SFML libraries. So I guess you haven't done the install step.
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #10 on: March 12, 2017, 07:35:58 pm »
I downloaded SFML source next i open this in CMake, next i choose when the CMake have to build the binaries and where is the source code, next i marked the SFML_USE_STATIC_STD_LIBS and i click Configure and Generate, next open the compiled of CMake in Visual Studio and click Build Solution in Debug and in Release.

After build solution i have this folder:


And i copy the libs from this folder /\ and include from SFML source to one folder. Next i set the path in visual studio to libs and include. But i dont have freetype.lib, only lib type "sfml-window-s.lib"
« Last Edit: March 12, 2017, 07:45:31 pm by Sebox »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Static linking problem
« Reply #11 on: March 12, 2017, 07:46:35 pm »
If you build the INSTALL target (project) in Visual Studio you don't have to copy anything around.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #12 on: March 12, 2017, 08:28:48 pm »
It is explained in the CMake tutorial, just read it (search "install" if you can't find where it is explained -- hint: it's at the end ;)).
Laurent Gomila - SFML developer

Sebox

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Static linking problem
« Reply #13 on: March 12, 2017, 08:34:16 pm »
When i build INSTALL in visual studio i get error:

MSB3073 The command "setlocal
C:\Users\Sebastian\Desktop\cmake-3.8.0-rc2-win32-x86\bin\cmake.exe -DBUILD_TYPE=Debug -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd"
exited with code 1.     INSTALL

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static linking problem
« Reply #14 on: March 13, 2017, 06:32:20 am »
Is your CMAKE_INSTALL_PREFIX in C:\Program Files ? If so, you need admin rights (so I personally never install there).
Laurent Gomila - SFML developer