C语言 交叉编译问题-动态



我一直在尝试在wsl2上交叉编译libsound库到windows 10。

我使用了库的github中描述的步骤。Session "Building for Windows">

但是,我在执行cmake时遇到了一些问题:

cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe/usr/x86_64-w64-mingw32.static/share/cmake/mxe-conf.cmake

命令返回:

-- The C compiler identification is GNU 5.5.0
-- Check for working C compiler: /home/andre/git/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64- 
mingw32.static-gcc
-- Check for working C compiler: /home/andre/git/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64- 
mingw32.static-gcc -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/home/andre/git/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64-mingw32.static-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/andre/git/libsoundio/build-win64/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_8a923/fast && /usr/bin/make -f 
CMakeFiles/cmTC_8a923.dir/build.make CMakeFiles/cmTC_8a923.dir/build
make[1]: Entering directory '/home/andre/git/libsoundio/build-win64/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8a923.dir/testCCompiler.c.o
/home/andre/git/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64-mingw32.static-gcc    -o 
CMakeFiles/cmTC_8a923.dir/testCCompiler.c.o   -c /home/andre/git/libsoundio/build- 
win64/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_8a923
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8a923.dir/link.txt --verbose=1
/home/andre/git/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64-mingw32.static-gcc      -rdynamic 
CMakeFiles/cmTC_8a923.dir/testCCompiler.c.o  -o cmTC_8a923
x86_64-w64-mingw32.static-gcc: error: unrecognized command line option '-rdynamic'
make[1]: *** [CMakeFiles/cmTC_8a923.dir/build.make:87: cmTC_8a923] Error 1
make[1]: Leaving directory '/home/andre/git/libsoundio/build-win64/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_8a923/fast] Error 2


CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
See also "/home/andre/git/libsoundio/build-win64/CMakeFiles/CMakeOutput.log".
See also "/home/andre/git/libsoundio/build-win64/CMakeFiles/CMakeError.log".

/home/andre/git/libsoundio/build-win64/CMakeFiles/.

我遵循github中描述的所有指示。

有人知道发生了什么事吗?

我假设使用兼容mingw的GCC构建的应用程序是与windows兼容的应用程序,尽管我不确定。-rdynamic仅与Linux/ELF目标相关。您可能需要确保指定了正确的编译器,例如通过设置CC环境变量。

相关内容

  • 没有找到相关文章