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

Author Topic: Compiling SFML2.5.1 for x86 with CMake  (Read 1487 times)

0 Members and 1 Guest are viewing this topic.

josh1024

  • Newbie
  • *
  • Posts: 3
    • View Profile
Compiling SFML2.5.1 for x86 with CMake
« on: August 05, 2019, 05:07:04 pm »
I use Visual Studio 2019 x86 running on Winx64, and want use SFML to build x86 apps, so I tried to build SFML but failed.



I followed the provided tut:
https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php

...and I did get it to work, having it show that demo window with a green circle.

But it was only if the configuration is set to x64(I used Debug x64). Using x86 gives me a "LNK1112: module machine type 'x64' conflicts with target machine type 'x86'" error.

I figured I have built the library for x64, not x86, so I attempted to rebuild a x86 one.



I re-opened CMake and during Gererator Setup(CMake Setup), below "Specify the generator for this project" is "Optional platform for generator(if empty, generator uses: x64)", and I set it to "Win32". The rest if the process is the same as before.

But now(config: Debug x86), I get another error "LNK1104: cannot open file'sfml-audio-d.lib'". As I did got it to work, I know that the paths are right, so apparently now the new files I made can't be opened.



So, my question is, how do you properly build a lib for x86? What went wrong?

G.

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile
Re: Compiling SFML2.5.1 for x86 with CMake
« Reply #1 on: August 05, 2019, 05:12:55 pm »
I know you said the path to your .lib si right, but it's worth double/triple checking it because this error message usually means that it can't find the file. (wrong path, typo in the name of the lib or the path, forget to add the path to your lib in "additional library directories", ...)

josh1024

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Compiling SFML2.5.1 for x86 with CMake
« Reply #2 on: August 05, 2019, 05:23:52 pm »
Uh, first off, my apologies, the file name is wrong.

The new lib doesn't distinguish between regular".lib" and "-d.lib" meant for debug, and I didn't notice that. Sorry.

But, new question: is it meant to be that way, x64 lib having files not in a x86 files(correction: lib)? or is this just how it has been implemented?

G.

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile
Re: Compiling SFML2.5.1 for x86 with CMake
« Reply #3 on: August 05, 2019, 06:00:46 pm »
I'm not sure I understand the question, but if you want the -d version you have to compile too.
In CMake, choose Debug in CMAKE_BUILD_TYPE when generating the project to build the debug version of SFML.

josh1024

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Compiling SFML2.5.1 for x86 with CMake
« Reply #4 on: August 06, 2019, 03:18:51 pm »
For some reason, I got both -d and non-d libs when building the x64 one, so I was really confused when building x86 turned out differently.

I want to say that, I'm sure I only built the x64 project generated as Release in CMake once, and somehow got both libs, but now I'm not so sure that I remember correctly...

Anyways, I built the d-libs and things are working now. Just for records, the demo window showed up even if I used non-d-libs in Debug mode, but now that I do have the d-libs I suppose that I shouldn't have anymore issues with installation from here on.



One last thing: there are libs without a "-d" variant, such as flac.lib. Are they the same file for x86 and x64? They're named the same in both cases, and the few dozens of lines of code that I've checked are identical, but I just wanna be sure.

And thanks for the prompt help!

 

anything