我有一个 C++ 库,由 Gradle 在 Mac for Windows 上使用 mingw-w64 进行交叉编译。当链接器尝试链接二进制文件时,我得到一个“错误的 -rpath 选项”。
下面的调试输出中有一个复杂的链接器搜索路径,为了清楚起见,我已将其删除,但它们都可以。但是,有一个部分似乎是错误的 - 似乎某些内容被错误地添加到了搜索路径中。
:linkWindows-x8664DebugTestSharedLibrary
Using built-in specs.
COLLECTGCC=/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/bin/g++
Target: x8664-w64-mingw32
Configured with: ../source/gcc-4.8.3/configure --build=x8664-apple-darwin13.2.0 --target=x8664-w64-mingw32 --disable-nls --disable-multilib --prefix=/usr/local/bin/mingw-w64/mingw-w64-x8664 --with-sysroot=/usr/local/bin/mingw-w64/mingw-w64-x8664 --with-mpc=/usr/local/bin/mingw-w64/pkgs/mpc/mpc-1.0.2-x8664 --with-mpfr=/usr/local/bin/mingw-w64/pkgs/mpfr/mpfr-3.1.2-x8664 --with-gmp=/usr/local/bin/mingw-w64/pkgs/gmp/gmp-6.0.0a-x8664 --with-host-libstdcxx='-lstdc++ ' --with-cloog=/usr/local/bin/mingw-w64/pkgs/cloog/cloog-0.18.0-x8664 --with-isl=/usr/local/bin/mingw-w64/pkgs/isl/isl-0.11.1-x8664 --enable-languages=c,c++ --enable-threads=win32 --enable-fully-dynamic-string --enable-lto
Thread model: win32
gcc version 4.8.3 (GCC)
COMPILERPATH=/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/
LIBRARYPATH=/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/lib/../lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/lib/
COLLECTGCCOPTIONS='-shared' '-o' '/Users/john/git/test/build/binaries/testSharedLibrary/windows-x8664Debug/libtest.dylib' '-L/Users/john/git/test/build/nar-dependencies/compiletestWindows-x8664Debug/lib' '-v' '-fno-use-linker-plugin' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/ld --sysroot=/usr/local/bin/mingw-w64/mingw-w64-x8664 -m i386pep --shared -Bdynamic -e DllMainCRTStartup --enable-auto-image-base -o /Users/john/git/test/build/binaries/testSharedLibrary/windows-x8664Debug/libtest.dylib /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/dllcrt2.o /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/crtbegin.o -LseriesOfSearchFoldersHereEachWithMinusLFlag **@/var/folders/75/fsklv28523d2gx1wth3rc7y0000101/T//ccOUlRAe** -lmingw32 -lgccs -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgccs -lgcc -lmoldname -lmingwex -lmsvcrt /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/crtend.o
Error message reads:
/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/ld: bad -rpath option
FAILED
这似乎是导致问题的有问题的位:@/var/folders/75/fsklv28523d2gx1wth3rc7y0000101/T//ccOUlRAe
那是什么,为什么会在那里?