简体   繁体   English

CMake 和 vcpkg x86_64-w64-mingw32/bin/ld:交叉编译时找不到 -lOpenGL32

[英]CMake and vcpkg x86_64-w64-mingw32/bin/ld: cannot find -lOpenGL32 when cross compiling

I'm making project which uses sfml, imgui-sfml and nlohmann json.我正在制作使用 sfml、imgui-sfml 和 nlohmann json 的项目。 For my dependences im using vcpkg.对于我的依赖,我使用 vcpkg。 My host machine is Arch and I wanna cross build to Windows x64.我的主机是 Arch,我想交叉构建到 Windows x64。 Im getting strange linking error, am I missing something easy here?我收到奇怪的链接错误,我在这里遗漏了一些简单的东西吗? Here is my toolchain file:这是我的工具链文件:

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x64)

# which tools to use
set(CMAKE_PREFIX_PATH /usr/x86_64-w64-mingw32/)
set(CMAKE_C_COMPILER   /usr/bin/x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)

set(CMAKE_FIND_ROOT_PATH  /usr/x86_64-w64-mingw32)


# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

here is my custom triplet:这是我的自定义三元组:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /home/bor/Dokumenty/proj/sokoban/toolchain-minwin.cmake)

my CMakeLists.txt(im not using anywhere raw opengl, only sfml)我的 CMakeLists.txt(我没有在任何地方使用原始 opengl,只有 sfml)

cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0079 NEW)

project(sokoban VERSION 0.0.0
                DESCRIPTION "Sokoban"
                LANGUAGES CXX)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif()


#c++17 standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_compile_options(-std=c++17)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(src)

#commented or not same error
find_package(OpenGL REQUIRED)

find_package(freetype CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(SFML COMPONENTS system window graphics CONFIG REQUIRED)
find_package(ImGui-SFML CONFIG REQUIRED)
find_package(imgui CONFIG REQUIRED)

target_link_libraries(sokoban PRIVATE nlohmann_json nlohmann_json::nlohmann_json)
target_link_libraries(sokoban PRIVATE sfml-system sfml-network sfml-graphics sfml-window)
target_link_libraries(sokoban PRIVATE ImGui-SFML::ImGui-SFML)
target_link_libraries(sokoban PRIVATE imgui::imgui)
target_link_libraries(sokoban PRIVATE freetype)

and my error和我的错误

[bor@b0x build]$ cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/bor/Dokumenty/proj/vcpkg/scripts/buildsystems/vcpkg.cmake  -DVCPKG_TARGET_TRIPLET=x64-custom -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/bor/Dokumenty/proj/sokoban/toolchain-minwin.cmake
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: opengl32   
-- Found ZLIB: optimized;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/lib/libzlib.a;debug;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/debug/lib/libzlibd.a (found version "1.2.11") 
-- Found BZip2: optimized;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/lib/libbz2.a;debug;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/debug/lib/libbz2d.a (found version "1.0.8") 
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Found PNG: optimized;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/debug/lib/libpng.a;debug;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/debug/lib/libpng16d.a (found version "1.6.37") 
-- Found nlohmann_json: /home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/share/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.9.1") 
-- Found Freetype: optimized;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/lib/libfreetype.a;debug;/home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/debug/lib/libfreetyped.a (found version "2.10.4") 
-- Found SFML 2.5.1 in /home/bor/Dokumenty/proj/vcpkg/installed/x64-custom/share/sfml
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bor/Dokumenty/proj/sokoban/build
[bor@b0x build]$ make
Scanning dependencies of target sokoban
[ 10%] Building CXX object src/CMakeFiles/sokoban.dir/main.cpp.obj
[ 20%] Building CXX object src/CMakeFiles/sokoban.dir/Game.cpp.obj
[ 30%] Building CXX object src/CMakeFiles/sokoban.dir/states/PlayingState.cpp.obj
[ 40%] Building CXX object src/CMakeFiles/sokoban.dir/states/MainMenuState.cpp.obj
[ 50%] Building CXX object src/CMakeFiles/sokoban.dir/states/LevelEditorState.cpp.obj
[ 60%] Building CXX object src/CMakeFiles/sokoban.dir/Level.cpp.obj
[ 70%] Building CXX object src/CMakeFiles/sokoban.dir/LevelConfig.cpp.obj
[ 80%] Building CXX object src/CMakeFiles/sokoban.dir/objects/Player.cpp.obj
[ 90%] Building CXX object src/CMakeFiles/sokoban.dir/map/Map.cpp.obj
[100%] Linking CXX executable ../sokoban.exe
/usr/lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lOpenGL32
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/sokoban.dir/build.make:255: sokoban.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:133: src/CMakeFiles/sokoban.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

I managed to get this to work by symlinking libopengl32.a with libOpenGL32.a.我设法通过将 libopengl32.a 与 libOpenGL32.a 符号链接来使其工作。 Maybe its dirty but atleast it works.也许它很脏,但至少它有效。 I don't know if that is typo in imgui/sfml packages or what.我不知道这是 imgui/sfml 包中的错字还是什么。

ln -s /usr/x86_64-w64-mingw32/lib/libopengl32.a /usr/x86_64-w64-mingw32/lib/libOpenGL32.a

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 严重错误:sys / socket.h:没有此类文件或目录,x86_64-w64-mingw32模式 - fatal error: sys/socket.h: No such file or directory, x86_64-w64-mingw32 mode 使用x86_64-w64-mingw32-g ++进行OMP交叉编译 - OMP Cross compilation with x86_64-w64-mingw32-g++ x86_64-w64-mingw32-g ++编译失败,g ++正常工作 - x86_64-w64-mingw32-g++ fails to compile, g++ works fine 带有 x86-64-w64-mingw32-g++ 未定义引用的 libcurl。 g++ 工作正常 - libcurl with x86-64-w64-mingw32-g++ undefined reference. g++ works fine 交叉编译gstreamer失败:x86-64 - > ARMv6 32位 - cross compiling gstreamer fails: x86-64 -> ARMv6 32-bit /usr/bin/ld: 在搜索 -lstdc++ 时跳过不兼容的 /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a /usr/bin/ld: 找不到 -lstdc++ - /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ 在Linux上与mingw-w64交叉编译时的声明冲突 - Conflicting declaration when cross compiling with mingw-w64 on Linux 在Fedora 20 x86_64上编译32位linux应用程序时使用sndfile库 - using sndfile library when compiling 32bit linux application on Fedora 20 x86_64 g ++找到-lXext,但是MinGW找不到它并显示错误:i586-mingw32msvc / bin / ld:找不到-lXext - g++ finds -lXext but MinGW cannot find it with error: i586-mingw32msvc/bin/ld: cannot find -lXext 制作共享库(64位NASM + gcc)时,不能使用针对.data的重定位R_X86_64_32S - Relocation R_X86_64_32S against .data cannot be used when making a shared object (64 bit NASM + gcc)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM