SFML community forums

Help => General => Topic started by: Kvaz1r on October 14, 2020, 04:01:27 pm

Title: CMAKE error missing dependencies of SFML
Post by: Kvaz1r on October 14, 2020, 04:01:27 pm
I want to use SFML with CMAKE but get error:

Quote
CMake Error at /SFML-2.5.1/build/SFMLConfig.cmake:139 (message):
  SFML found but some of its dependencies are missing ( FreeType OpenAL
  VorbisFile VorbisEnc Vorbis Ogg FLAC)
Call Stack (most recent call first):
  CMakeLists.txt:11 (find_package)


CMake Error at CMakeLists.txt:11 (find_package):
  Found package configuration file:

    /SFML-2.5.1/build/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.


Configuring incomplete, errors occurred!

CMake file:

cmake_minimum_required(VERSION 3.1)

project(SFMLTest)

## If you want to link SFML statically
set(SFML_STATIC_LIBRARIES TRUE)

## In most cases better set in the CMake cache
set(SFML_DIR "SFML-2.5.1\\build")

find_package(SFML 2.5.1 COMPONENTS graphics audio REQUIRED)
add_executable(SFMLTest appl.cpp)
target_link_libraries(SFMLTest sfml-graphics)

I use static SFML 2.5.1 that built myself with CMAKE.
Title: Re: CMAKE error missing dependencies of SFML
Post by: eXpl0it3r on October 14, 2020, 06:12:07 pm
Looks like you don't have static libraries built.
Title: Re: CMAKE error missing dependencies of SFML
Post by: Kvaz1r on October 14, 2020, 06:35:36 pm
If I define paths manually:
Quote
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "SFML-2.5.1\\extlibs\\headers")   
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "SFML-2.5.1\\extlibs\\libs-msvc\\x86")   
CMAKE generate project files.
Title: Re: CMAKE error missing dependencies of SFML
Post by: cmathai on October 25, 2023, 05:21:33 am
I have the same issue too.

This doesnt happen with SFML built as shared library.

I have this problem when SFML is built as a static library.
Title: Re: CMAKE error missing dependencies of SFML
Post by: eXpl0it3r on October 25, 2023, 09:30:13 am
I have the same issue too.
Can you be a bit more specific?
Title: Re: CMAKE error missing dependencies of SFML
Post by: cmathai on October 25, 2023, 10:36:43 pm
OK I made some more progress. Basically the original issue was because I was not linking the target against SFML dependencies (which I missed, although described in https://www.sfml-dev.org/tutorials/2.6/start-vc.php)

Here is the issue I have now - I built a static version of SFML myself. I took an SFML toy example, but got a lot of link errors when building my application.

Here are the steps I followed (and how I fixed it)

The last step gives a lot of link errors. Eg:-

Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj SFMLTest sfml-graphics-s.lib(Color.obj)
   

To fix this, I did the following.
Right click SFMLTest, click on properties.
C/C++ > Code Generation > Runtime Library is set to 'Multi-threaded DLL (/MD)'.

I changed it to 'Multi-threaded (/MT)' .

What I do not understand is, if I use the the pre-built version of SFML for VS 2019 from https://www.sfml-dev.org/files/SFML-2.6.0-windows-vc16-64-bit.zip, it works out of the box. And interestingly, when I check the solution generated with this, I still have Multi-threaded DLL (/MD), but it works. I am curious about why this works.

So I can't quite figure out what I am doing wrong. Any help is appreciated.
Title: Re: CMAKE error missing dependencies of SFML
Post by: eXpl0it3r on October 25, 2023, 11:40:54 pm
The difference/issue is:

and check SFML_USE_STATIC_STD_LIBS

That says to use static standard libs (i.e. /MT), which then requires that you also use static standard libs.

You can also solve this in CMake with:
set_property(TARGET my-target PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Title: Re: CMAKE error missing dependencies of SFML
Post by: cmathai on October 26, 2023, 12:34:33 am
Thanks!!!

That was the problem  :)