在构建SFML时CMake未链接

时间:2019-06-17 08:01:01

标签: c++ cmake sfml

我有我的项目,该项目嵌套在另一个目录中,其中包含项目所需的库。我使用的是与Clion(3.14)捆绑在一起的cmake。我正在使用带有cmake的子目录。我已经建立好了,但是没有链接SFML

根-|       -lib1       -smfl       -lib3       -my_project

我尝试使用诸如使用'target_link_directories()'之类的方法,但是我做错了,或者这绝对不是正确的选择。

根CMakeList.txt

Operations API

./ Purrmaid / CMakeList.txt

cmake_minimum_required(VERSION 3.10)

include_directories("ChaiScript/include" Catch2/include freetype2/include SFML/include )

add_subdirectory(Catch2)
add_subdirectory(ChaiScript)
add_subdirectory(freetype2)
add_subdirectory(SFML)


add_subdirectory(Purrmaid)

cmake_minimum_required (VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
project (purrmaid)



add_executable( purrmaid
        main.cpp
        Base_Object.cpp
        ...
        ThreadManager.cpp)

target_link_libraries(purrmaid sfml-system sfml-window sfml-graphics sfml-network sfml-audio pthread dl)

1 个答案:

答案 0 :(得分:2)

显示的错误是SFML无法链接,因为它找不到对不同的FT_符号(FT_MulFixFT_Init_FreeType等)的引用

这些由FreeType库定义。我假设您add_subdirectory(SFML)

时正在构建不同的SFML目标。

CMakeLists.txt子目录的SFML文件中,您是否将sfml-graphics目标链接到Free类型?

add_library(sfml-graphics
            ...)

# This is assuming you have a "freetype2" target available
# please replace by the actual name of the freetype target
target_link_libraries(sfml-graphics freetype2 ...)

编辑:感谢 Tsyvarev 将我指向无法链接的实际目标。

相关问题