我正在尝试将libobjc2从 Arch 交叉编译到 Windows。我使用以下命令来配置 CMake:
cmake .. -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS=$CLANG_WINDOWS_XFLAGS -DCMAKE_CXX_FLAGS=$CLANG_WINDOWS_XFLAGS -DCMAKE_INSTALL_PREFIX:PATH=/opt/cross/windows/gnustep
CLANG_WINDOWS_XFLAGS
定义为:
export CLANG_WINDOWS_XFLAGS="-target x86_64-w64-mingw32 -nostdinc -isystem /usr/lib/clang/3.6.0/include -isystem /usr/x86_64-w64-mingw32/include -isystem /usr/x86_64-w64-mingw32/include/c++/5.1.0 -isystem /usr/x86_64-w64-mingw32/include/c++/5.1.0/backward -isystem /usr/x86_64-w64-mingw32/include/c++/5.1.0/x86_64-w64-mingw32"
运行后make
,libobjc.dll
产品构建成功,但失败:
Linking C shared library libobjc.dll
[ 39%] Built target objc
Scanning dependencies of target objcxx
[ 40%] Building CXX object CMakeFiles/objcxx.dir/objcxx_eh.cc.obj
Linking C shared library libobjcxx.dll
CMakeFiles/objcxx.dir/objects.a(objcxx_eh.cc.obj):(.text+0x24c): undefined reference to `object_getClass'
CMakeFiles/objcxx.dir/objects.a(objcxx_eh.cc.obj):(.text+0x261): undefined reference to `objc_getClass'
CMakeFiles/objcxx.dir/objects.a(objcxx_eh.cc.obj):(.text+0x314): undefined reference to `objc_getClass'
CMakeFiles/objcxx.dir/objects.a(objcxx_eh.cc.obj):(.text+0x32c): undefined reference to `objc_getClass'
CMakeFiles/objcxx.dir/objects.a(objcxx_eh.cc.obj):(.text+0x3ac): undefined reference to `class_getSuperclass'
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
CMakeFiles/objcxx.dir/build.make:87: recipe for target 'libobjcxx.dll' failed
make[2]: *** [libobjcxx.dll] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/objcxx.dir/all' failed
make[1]: *** [CMakeFiles/objcxx.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2
我似乎无法让 MinGW 链接libobjcxx.dll
到libobjc.dll
. 该库在不交叉编译时编译成功。
任何有关如何使其工作的提示将不胜感激。