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

Author Topic: Can't build a static-library project for Windows XP  (Read 2506 times)

0 Members and 1 Guest are viewing this topic.

metafurionx

  • Newbie
  • *
  • Posts: 13
    • View Profile
Can't build a static-library project for Windows XP
« on: January 01, 2017, 02:14:47 am »
I want to create a C++/SFML game that runs in Windows XP and doesn't ask the user for MSVCP140.dll.

I'm using SFML 2.4.1 for Windows (Visual C++ 14 (2015) - 32-bit) with Microsoft Visual Studio Community 2015.
I'm working in Windows 10 and using Windows XP in a virtual machine to test this.
I tried to ship whatever it needs with the program, but at some point it asks for something that isn't a file.
Then I believe I have to make it a static-library project.
So I followed the tutorial for SFML 2.4 and Visual Studio.

Reproducing my steps adapted to the case:

I open Visual Studio > New Project > C++ (.NET Framework 4.5.2) > Win32 Console Application > name it "test" > check "Empty project" > click Finish
Create a "main.cpp" inside "Source Files" branch
Put "SFML-2.4.1" folder into "C:\"
Open the Property window for my project
Set Configuration to "All Configurations"
General > Platform Toolset > Visual Studio 2015 - Windows XP (v140_xp)
C/C++ > General > Additional Include Directiories > "C:\SFML-2.4.1\include"
Linker > General > Additional Library Directiories > "C:\SFML-2.4.1\lib"
Set Configuration to "Debug"
C/C++ > Preprocessor > Preprocessor Definitions > prepend "SFML_STATIC;"
C/C++ > Code Generation > Runtime Library > Multi-threaded Debug (/MTd)
Linker > Input > Additional Dependencies > prepend "sfml-graphics-s-d.lib;sfml-window-s-d.lib;sfml-system-s-d.lib;"
Set Configuration to "Release"
C/C++ > Preprocessor > Preprocessor Definitions > prepend "SFML_STATIC;"
C/C++ > Code Generation > Runtime Library > Multi-threaded (/MT)
Linker > Input > Additional Dependencies > prepend "sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;"
Then I go back to the project, copy the code from the tutorial to "main.cpp" and try to run Build Solution.

Debug (x86): 171 Errors and 87 Warnings
First error: LNK2038 mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in main.obj
Release (x86): 105 Errors and 1 Warning
First error: LNK2038 mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj

I thought I did everything needed for a static-library project, but something is still dynamic. I don't know what to do from here. Please, help?
« Last Edit: January 01, 2017, 02:27:20 am by metafurionx »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Can't build a static-library project for Windows XP
« Reply #1 on: January 01, 2017, 08:22:38 am »
The SFML libraries have been.built with /MD and /MDd. If you want them to use /MT and /MTs, you'll have to rebuild SFML yourself and make sure to check UST_STATIC_STD_LIBS in the CMake option.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

metafurionx

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Can't build a static-library project for Windows XP
« Reply #2 on: January 02, 2017, 07:22:14 pm »
Oops, I have to set static libraries on Visual Studio's side, not SFML's.
Yeah, gotta do that.

metafurionx

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Can't build a static-library project for Windows XP
« Reply #3 on: January 03, 2017, 05:08:07 am »
...And I did it! I followed the tut0r1al carefully, checked SFML_USE_STATIC_STD_LIBS but also unchecked BUILD_SHARED_LIBS.
I can't believe it. My game (C++14, SFML 2.4.1) is now a single .exe that runs on Windows XP or newer without the need to install any crap! It's beautiful. :'D

Thanks.

 

anything