Vinculei as bibliotecas SFML e TGUI em meu projeto. Também incluí essas bibliotecas em outro CMakeLists deste projeto. Quando começo a construir o projeto, recebo uma mensagem informando que os arquivos dessas bibliotecas não podem ser encontrados. E toda vez parece estar conectado apenas com TGUI. Até tentei usar target_include_directories para incluir os arquivos de cabeçalho da biblioteca, mas não adiantou. Além disso, este projeto lista ambas as bibliotecas no cabeçalho do caminho de pesquisa.
C:\Users\vinog\CLionProjects\url-player\ui\include\music_list.h(3): fatal error C1083: Cannot open include file: 'TGUI/Backend/SFML-Graphics.hpp': No such file or directory
mingw32-make[3]: *** [CMakeFiles\url_player.dir\build.make:75: CMakeFiles/url_player.dir/main.cpp.obj] Error 2
mingw32-make[2]: *** [CMakeFiles\Makefile2:137: CMakeFiles/url_player.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:144: CMakeFiles/url_player.dir/rule] Error 2
mingw32-make: *** [Makefile:123: url_player] Error 2
Eu sei que bibliotecas foram fundadas. Porque vejo o conteúdo da mensagem.
Eu incluo bibliotecas como esta:
set(SFML_DIR ${SFML_PATH})
find_package(SFML COMPONENTS system window graphics REQUIRED PATHS ${SFML_DIR})
set(TGUI_DIR ${TGUI_PATH})
find_package(TGUI REQUIRED PATHS ${TGUI_DIR})
Eu tento incluir estes arquivos:
#include <TGUI/Backend/SFML-Graphics.hpp>
#include <TGUI/Widgets/Panel.hpp>
Listas Cmake:
add_library(ui STATIC
src/music_list.cpp
src/button.cpp
ui-config/src/json-ui-config.cpp
src/menu.cpp
)
target_include_directories(ui PRIVATE ${TGUI_INCLUDE_DIR} include ${CMAKE_SOURCE_DIR}/json ui-config/include)
target_link_libraries(ui PRIVATE tgui sfml-system sfml-graphics sfml-window sfml-main music-storage json-storage)
Tentei limpar o cache, recarregar o projeto CMake, vincular novamente as bibliotecas e recriar a classe onde ocorre o erro.
linha de comando completa:
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -SC:\Users\vinog\CLionProjects\url-player -BC:\Users\vinog\CLionProjects\url-player\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
C:/mingw/bin/mingw32-make.exe -f CMakeFiles\Makefile2 url_player
mingw32-make[1]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -SC:\Users\vinog\CLionProjects\url-player -BC:\Users\vinog\CLionProjects\url-player\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_progress_start C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\CMakeFiles 11
C:/mingw/bin/mingw32-make.exe -f CMakeFiles\Makefile2 CMakeFiles/url_player.dir/all
mingw32-make[2]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
C:/mingw/bin/mingw32-make.exe -f storage\CMakeFiles\json-storage.dir\build.make storage/CMakeFiles/json-storage.dir/depend
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\vinog\CLionProjects\url-player C:\Users\vinog\CLionProjects\url-player\storage C:\Users\vinog\CLionProjects\url-player\cmake-build-debug C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\storage C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\storage\CMakeFiles\json-storage.dir\DependInfo.cmake "--color="
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
C:/mingw/bin/mingw32-make.exe -f storage\CMakeFiles\json-storage.dir\build.make storage/CMakeFiles/json-storage.dir/build
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 9%] Linking CXX static library json-storage.lib
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\storage && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -P CMakeFiles\json-storage.dir\cmake_clean_target.cmake
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\storage && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_link_script CMakeFiles\json-storage.dir\link.txt --verbose=1
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\lib.exe /nologo /machine:x64 /out:json-storage.lib @CMakeFiles\json-storage.dir\objects1.rsp
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 18%] Built target json-storage
C:/mingw/bin/mingw32-make.exe -f music-storage\CMakeFiles\music-storage.dir\build.make music-storage/CMakeFiles/music-storage.dir/depend
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\vinog\CLionProjects\url-player C:\Users\vinog\CLionProjects\url-player\music-storage C:\Users\vinog\CLionProjects\url-player\cmake-build-debug C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\music-storage C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\music-storage\CMakeFiles\music-storage.dir\DependInfo.cmake "--color="
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
C:/mingw/bin/mingw32-make.exe -f music-storage\CMakeFiles\music-storage.dir\build.make music-storage/CMakeFiles/music-storage.dir/build
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 27%] Linking CXX static library music-storage.lib
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\music-storage && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -P CMakeFiles\music-storage.dir\cmake_clean_target.cmake
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\music-storage && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_link_script CMakeFiles\music-storage.dir\link.txt --verbose=1
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\lib.exe /nologo /machine:x64 /out:music-storage.lib @CMakeFiles\music-storage.dir\objects1.rsp
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 36%] Built target music-storage
C:/mingw/bin/mingw32-make.exe -f ui\CMakeFiles\ui.dir\build.make ui/CMakeFiles/ui.dir/depend
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\vinog\CLionProjects\url-player C:\Users\vinog\CLionProjects\url-player\ui C:\Users\vinog\CLionProjects\url-player\cmake-build-debug C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\ui C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\ui\CMakeFiles\ui.dir\DependInfo.cmake "--color="
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
C:/mingw/bin/mingw32-make.exe -f ui\CMakeFiles\ui.dir\build.make ui/CMakeFiles/ui.dir/build
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 45%] Linking CXX static library ui.lib
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\ui && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -P CMakeFiles\ui.dir\cmake_clean_target.cmake
cd /d C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\ui && "C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_link_script CMakeFiles\ui.dir\link.txt --verbose=1
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\lib.exe /nologo /machine:x64 /out:ui.lib @CMakeFiles\ui.dir\objects1.rsp
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 81%] Built target ui
C:/mingw/bin/mingw32-make.exe -f CMakeFiles\url_player.dir\build.make CMakeFiles/url_player.dir/depend
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\vinog\CLionProjects\url-player C:\Users\vinog\CLionProjects\url-player C:\Users\vinog\CLionProjects\url-player\cmake-build-debug C:\Users\vinog\CLionProjects\url-player\cmake-build-debug C:\Users\vinog\CLionProjects\url-player\cmake-build-debug\CMakeFiles\url_player.dir\DependInfo.cmake "--color="
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
C:/mingw/bin/mingw32-make.exe -f CMakeFiles\url_player.dir\build.make CMakeFiles/url_player.dir/build
mingw32-make[3]: Entering directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
[ 90%] Building CXX object CMakeFiles/url_player.dir/main.cpp.obj
"C:\Program Files\JetBrains\CLion 2024.1.4\bin\cmake\win\x64\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\url_player.dir\main.cpp.obj.d --working-dir=C:\Users\vinog\CLionProjects\url-player\cmake-build-debug --filter-prefix="Note: including file: " -- C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\cl.exe /nologo /TP /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++17 -MDd -Zi /showIncludes /FoCMakeFiles\url_player.dir\main.cpp.obj /FdCMakeFiles\url_player.dir/ /FS -c C:\Users\vinog\CLionProjects\url-player\main.cpp
main.cpp
C:\Users\vinog\CLionProjects\url-player\ui\include\music_list.h(3): fatal error C1083: Cannot open include file: 'TGUI/Backend/SFML-Graphics.hpp': No such file or directory
mingw32-make[3]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
mingw32-make[2]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
mingw32-make[1]: Leaving directory 'C:/Users/vinog/CLionProjects/url-player/cmake-build-debug'
mingw32-make[3]: *** [CMakeFiles\url_player.dir\build.make:78: CMakeFiles/url_player.dir/main.cpp.obj] Error 2
mingw32-make[2]: *** [CMakeFiles\Makefile2:140: CMakeFiles/url_player.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:147: CMakeFiles/url_player.dir/rule] Error 2
mingw32-make: *** [Makefile:126: url_player] Error 2
O problema está no seu
url_player
alvo, não noui
alvo. Você passouPRIVATE
para otarget_include_directories
comando, o que significa queurl_player
não recebe os caminhos de inclusão que você configurouui
.Altere para
PRIVATE
(PUBLIC
para que seja propagado) ou adicione um explícitoAlém disso, observe o CMake moderno, onde os diretórios de inclusão fazem parte do destino da biblioteca TGUI e você apenas vincula a ele em vez de configurar os diretórios de inclusão separadamente.