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

Author Topic: Question regarding the placement of libsfml (32/64 bits) on Windows  (Read 906 times)

0 Members and 1 Guest are viewing this topic.

jackcmedia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Hi,

I have a question related to where should I place the SFML2 libraries to allow me to compile both x86 and x64 applications using CMake and TDM-GCC's MinGW for Windows x64.

Browsing the FindSFML.cmake module, I read that it looks for the libraries on a lib folder, which can be located on a myriad of locations (I'm using an environment variable). It also looks inside the lib and lib64 subfolders, if applicable.

My question is, could I take advantage of that to have the libraries for x86 and x64 coexisting in the same location? Or would that be a bad practice?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10879
    • View Profile
    • development blog
    • Email
Re: Question regarding the placement of libsfml (32/64 bits) on Windows
« Reply #1 on: December 09, 2014, 08:38:55 pm »
Windows doesn't really provide a general place for third-party libraries.
As such the general way is to place them where ever you want and by setting SFML_ROOT to the root directory of SFML, will ensure that the FindSFML.cmake script will find it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jackcmedia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Question regarding the placement of libsfml (32/64 bits) on Windows
« Reply #2 on: December 09, 2014, 11:21:40 pm »
Windows doesn't really provide a general place for third-party libraries.
As such the general way is to place them where ever you want and by setting SFML_ROOT to the root directory of SFML, will ensure that the FindSFML.cmake script will find it.

I get that. In fact, I am using SFML_ROOT to point to the folder where I have placed SFML 2.1.

My question was oriented to the coexistence of both SFML 2.1 for x86 and x64 in the same folder. Right now, I have the following subfolders within it:
  • bin32 (dlls for x86)
  • bin64 (dlls for x64)
  • include (headers common to both x86 and x64)
  • lib32 (libs for x86)
  • lib64 (libs for x64)
The thing is that CMake cannot find the libraries unless I name the folder that contains them as "lib" but, if I do that, I get only the x86 or the x64 flavor. However, if I were to change the structure of the folders like this:
  • lib (base folder for libraries)
    • lib (libs for x86)
    • lib64 (libs for x64)
Then, I can compile for any of those architectures, just modifying an option in the CMake to add the -m32 parameter to the compiler flags. However, that sounds like a really dirty solution, so I don't know...


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10879
    • View Profile
    • development blog
    • Email
Re: Question regarding the placement of libsfml (32/64 bits) on Windows
« Reply #3 on: December 10, 2014, 01:09:25 am »
The thing is that CMake cannot find the libraries unless I name the folder that contains them as "lib" but, if I do that, I get only the x86 or the x64 flavor. However, if I were to change the structure of the folders like this:
  • lib (base folder for libraries)
    • lib (libs for x86)
    • lib64 (libs for x64)
Then, I can compile for any of those architectures, just modifying an option in the CMake to add the -m32 parameter to the compiler flags. However, that sounds like a really dirty solution, so I don't know...
Am I reading this right, that you want to run one make command and build a x86 and x64 at once?

I've no idea if you can use lib64 and lib in the same directory, since I don't fully understand the FindSFML.cmake, maybe you can try:
  • Don't cross-compile, but use a compiler for x86 binaries and one for x64 binaries.
  • Setup the SFML libraries as lib for the x86 binaries and lib64 for the x64 binaries.
  • Set SFML_ROOT
  • Hope CMake prefers lib64 for x64 compilers and lib for x86. If not, you'll probably have to use different directories for x86 and x64.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jackcmedia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Question regarding the placement of libsfml (32/64 bits) on Windows
« Reply #4 on: December 10, 2014, 06:38:06 pm »
Maybe you can try:
  • Don't cross-compile, but use a compiler for x86 binaries and one for x64 binaries.
  • Setup the SFML libraries as lib for the x86 binaries and lib64 for the x64 binaries.
  • Set SFML_ROOT
  • Hope CMake prefers lib64 for x64 compilers and lib for x86. If not, you'll probably have to use different directories for x86 and x64.

I guess I can install the 32 bit version of TDM-GCC's MinGW and provide the info using CLion's toolchain options.

CMake doesn't like the library folder being named anything other than "lib". There is a global property named FIND_LIBRARY_USE_LIB64_PATHS, which is supposed to allow to look inside both "lib" and "lib64" folders when looking for the appropriate libraries, but doesn't seem to work on Windows.

Incidentally, there was a proposal for a FIND_LIBRARY_USE_LIB32_PATHS global property, given that some systems place x64 libraries on the "lib" folder and x86 libraries on the "lib32" folder, but that ticket remains open and untouched since 2011. (At least is not like Windows' System32 for x64 libs and SysWow64 for x86 libs...)