CodeSourcery Lite 强制包含到 ARM9/ 的搜索路径
CodeSourcery Lite Forcing Include Search Path to ARM9/
我已经在 Ubuntu 中使用 CodeSourcery Lite 4.7.3 环境交叉编译了很长一段时间,并且正在过渡到基于 windows 的环境。我正在使用相同版本的 CodeSourcery, and using "GNU ARM Eclipse Build Tools 进行构建。”出于某种原因,当我在 windows 系统中构建 Ubuntu 中的项目时,当我将它们放在目标上时,它正在 ARM9/ 目录中搜索我构建的自定义共享库。
为了帮助理解运行时错误,我正在编译的是一个需要共享库的动态加载库。 "targetapp" 是预编译的,只有在 windows 环境中交叉编译 "dynamic_module" 时才会出现此错误(是的,我在 [=77] 中使用相同的编译命令=],linux,我只是更新了 eclipse 项目中的交叉编译器路径。
[root@(none) root]# ./targetapp | grep dynamic_module
Error opening dll '/home/root/dynamic_module': ARM9/libSharedLibrary.so: cannot open shared object file: No such file or directory
目标是带有 busybox 的精简定制香草 linux 系统。我只是无法理解为什么这个相对路径被嵌入到我在 Windows 中编译的库中,而不是在 Ubuntu.
中
下面是 Ubuntu 交叉编译器和 Windows 交叉编译器的编译器版本输出。
Ubuntu G++ -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure
-v
--with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++
--prefix=/usr
--program-suffix=-4.7
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.7.3
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-gnu-unique-object
--disable-libmudflap
--disable-libitm
--enable-plugin
--with-system-zlib
--enable-objc-gc
--with-cloog
--enable-cloog-backend=ppl
--disable-cloog-version-check
--disable-ppl-version-check
--enable-multiarch
--enable-multilib
--disable-sjlj-exceptions
--with-arch=armv5t
--with-float=soft
--disable-werror
--enable-checking=release
--build=i686-linux-gnu
--host=i686-linux-gnu
--target=arm-linux-gnueabi
--program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1)
Windows G++ -v
Using built-in specs.
COLLECT_GCC=arm-none-linux-gnueabi-g++.exe
COLLECT_LTO_WRAPPER=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.7.3/lto-wrapper.exe
Target: arm-none-linux-gnueabi
Configured with: /scratch/jbrown/2013.05-arm-linux-release/src/gcc-4.7-2013.05/configure
--build=i686-pc-linux-gnu
--host=i686-mingw32
--target=arm-none-linux-gnueabi
--enable-threads
--disable-libmudflap
--disable-libssp
--disable-libstdcxx-pch
--enable-extra-sgxxlite-multilibs
--with-arch=armv5te
--with-gnu-as
--with-gnu-ld
--with-specs='%{save-temps: -fverbose-asm}
%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}
-D__CS_SOURCERYGXX_MAJ__=2013
-D__CS_SOURCERYGXX_MIN__=5
-D__CS_SOURCERYGXX_REV__=24
%{O2:%{!fno-remove-local-statics: -fremove-local-statics}}
%{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}'
--enable-languages=c,c++
--enable-shared
--enable-lto
--enable-symvers=gnu
--enable-__cxa_atexit
--with-pkgversion='Sourcery CodeBench Lite 2013.05-24'
--with-bugurl=https://sourcery.mentor.com/GNUToolchain/
--disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/jbrown/2013.05-arm-linux-release/install/host-i686-mingw32/arm-none-linux-gnueabi/libc
--with-libiconv-prefix=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-gmp=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-mpfr=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-mpc=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-ppl=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic
-lm'
--with-cloog=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-libelf=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--disable-libgomp
--disable-libitm
--enable-poison-system-directories
--with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/obj/tools-i686-pc-linux-gnu-2013.05-24-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
--with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/obj/tools-i686-pc-linux-gnu-2013.05-24-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-24)
编辑
我一直在为此苦苦挣扎。它最初是在 windows 中使用 CMake 进行编译时出现的问题,CMake 脚本是由其他人构建的,但我拥有 "dynamic module" 和 "libSharedLibrary.so." "libSharedLibrary.so" 是已知的在架构上工作,并加载到“/usr/lib”以在目标上共享 linking。我首先使用标准 makefile 在 Ubuntu 下编译了 "dynamic_module",然后在 Windows 中尝试使用 CMake,在 Windows 中尝试使用标准 makefile,每个结果都相同。 CMake 脚本最初引用了 "ARM9" 路径,我怀疑它弄乱了我的环境变量或我的交叉环境的其他潜在组件。今天早上我将所有 "ARM9" 引用更改为 "ARM7",并且仍然将相同的相对路径转储到 "dynamic_module." 我可以使用以下命令检查 link 路径...
C:\Raw_SVN\dynamic_module>"C:\ARM_Cross\bin\arm-none-linux-gnueabi-readelf.exe" -a ARM7\dynamic_module | findstr "Shared l
ibrary:"
Type: DYN (Shared object file)
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libarmadillo.so.4]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libboost_serialization.so.1.55.0]
0x00000001 (NEEDED) Shared library: [libboost_date_time.so.1.55.0]
0x00000001 (NEEDED) Shared library: [ARM9/libSharedLibrary.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
我还得到了详细的 linker 命令,如下所示....
C:/ARM_Cross/bin/arm-none-linux-gnueabi-g++.exe
-v
-fPIC
-isystem C:/ARM_Cross/arm-none-linux-gnueabi/libc/include
-isystem C:/ARM_Cross/arm-none-linux-gnueabi/usr/include
-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib
-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib
-shared
-Wl,-soname,ARM7/libDynamic_Module.so
-o
ARM7/libDynamic_Module.so
"CMakeFiles/Dynamic_Module.dir/Dynamic_Module.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp1.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp2.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp3.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp4.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp5.cpp.o"
-llapack
-lf2c
-lblas
-lrt
-larmadillo
-lpthread
-lexpat
-lboost_serialization
-lboost_date_time
-lSharedLibrary
Using built-in specs.
COLLECT_GCC=C:/ARM_Cross/bin/arm-none-linux-gnueabi-g++.exe
COLLECT_LTO_WRAPPER=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/lto-wrapper.exe
Target: arm-none-linux-gnueabi
Configured with: /scratch/janisjo/arm-linux-lite/src/gcc-4.5-2011.03/configure
--build=i686-pc-linux-gnu
--host=i686-mingw32
--target=arm-none-linux-gnueabi
--enable-threads
--disable-libmudflap
--disable-libssp
--disable-libstdcxx-pch
--enable-extra-sgxxlite-multilibs
--with-arch=armv5te
--with-gnu-as
--with-gnu-ld
--with-specs='%{save-temps: -fverbose-asm}
%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}
-D__CS_SOURCERYGXX_MAJ__=2011
-D__CS_SOURCERYGXX_MIN__=3
-D__CS_SOURCERYGXX_REV__=41
%{O2:%{!fno-remove-local-statics: -fremove-local-statics}}
%{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}'
--enable-languages=c,c++
--enable-shared
--enable-lto
--enable-symvers=gnu
--enable-__cxa_atexit
--with-pkgversion='Sourcery
G++ Lite 2011.03-41'
--with-bugurl=https://support.codesourcery.com/GNUToolchain/
--disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/janisjo/arm-linux-lite/install/host-i686-mingw32/arm-none-linux-gnueabi/libc
--with-libiconv-prefix=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-gmp=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-mpfr=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-mpc=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-ppl=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic
-lm'
--with-cloog=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-libelf=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--disable-libgomp
--enable-poison-system-directories
--with-build-time-tools=/scratch/janisjo/arm-linux-lite/obj/tools-i686-pc-linux-gnu-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
--with-build-time-tools=/scratch/janisjo/arm-linux-lite/obj/tools-i686-pc-linux-gnu-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41)
COMPILER_PATH=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/;c:/arm_cross/bin/../libexec/gcc/;c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/bin/
LIBRARY_PATH=c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/;c:/arm_cross/bin/../lib/gcc/;c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/lib/;c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/lib/;c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/
COLLECT_GCC_OPTIONS='-v'
'-fPIC'
'-isystem'
'C:/ARM_Cross/arm-none-linux-gnueabi/libc/include'
'-isystem'
'C:/ARM_Cross/arm-none-linux-gnueabi/usr/include'
'-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib'
'-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib'
'-shared'
'-o'
'ARM7/libDynamic_Module.so'
'-shared-libgcc'
'-march=armv5te'
'-funwind-tables'
'-D__CS_SOURCERYGXX_MAJ__=2011'
'-D__CS_SOURCERYGXX_MIN__=3'
'-D__CS_SOURCERYGXX_REV__=41'
c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/collect2.exe
--sysroot=c:\arm_cross\bin\../arm-none-linux-gnueabi/libc
--eh-frame-hdr
-shared
-dynamic-linker /lib/ld-linux.so.3
-X
-m armelf_linux_eabi
-o ARM7/libDynamic_Module.so c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/crti.o c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/crtbeginS.o
-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib
-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib
-Lc:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2
-Lc:/arm_cross/bin/../lib/gcc
-Lc:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/lib
-Lc:/arm_cross/bin/../arm-none-linux-gnueabi/libc/lib
-Lc:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib
-soname
ARM7/libDynamic_Module.so
CMakeFiles/Dynamic_Module.dir/Dynamic_Module.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp1.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp2.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp3.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp4.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp5.cpp.o
-llapack
-lf2c
-lblas
-lrt
-larmadillo
-lpthread
-lexpat
-lboost_serialization
-lboost_date_time
-lSharedLibrary
-lstdc++
-lm
-lgcc_s
-lc
-lgcc_s
c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/crtendS.o
c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/crtn.o
make[2]: Leaving directory 'C:/Raw_SVN/Dynamic_Module'
在修改环境(cmake配置引用ARM7)的情况下,我无处可以找到这个神秘的link到"ARM9"。如评论所述,问题可能是我的 libSharedLibrary.so 是在 linux 中交叉编译的。我现在要在 Windows 中交叉编译它,看看是否有任何变化。
所以,玩够了,ARM 引用来自我环境中的某个地方,即使它不在 linker 命令中,它也被引入了。其他信息可能是什么告诉 linker 这样做,给定上面参考中发出的命令?
更新
抱歉花了这么长时间才更新这个问题,正如标记的答案中提到的,在我下面的评论中,我能够确定一个解决方案。
在 Whosebug 上找到的 Similar SONAME linking problems 帮助我将问题与我在 CMAKE 文件中需要的内容隔离开来。在编译 libSharedLibrary.so 库时,我在 CMakeLists.txt 的最后一行添加了以下内容。
SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY NO_SONAME 1)
如果我没记错的话,这可以防止将 SONAME 嵌入到库中(我相信它包含我神秘的亲戚 ARM9 参考)。如果 libSharedLibrary.so 中没有 SONAME 引用,那么进入 dynamic_module 的 libDynamicLibrary.so link 将使用提供的名称而不是它在其中编译的 SONAME。
再次感谢您的所有帮助,再次感谢 user1034749 让我更接近解决方案。
我在查看您的 link 命令,我想问题出在这里:
-Wl,-soname,ARM7/libDynamic_Module.so
if link 具有此类标志的共享库,然后 link main
用这样的库编程,然后:
evgeniy@localhost /tmp/test $ gcc -shared -o libfoo.so test.o
-Wl,-soname,ARM7/libDynamic_Module.so evgeniy@localhost /tmp/test $ gcc -Lpwd
main.c -lfoo evgeniy@localhost /tmp/test $ ./a.out
./a.out: error while loading shared libraries:
ARM7/libDynamic_Module.so: cannot open shared object file: No such
file or directory
你的问题几乎和你上面描述的一模一样,
为什么ARM9而不是ARM7,可能只能在你这边解决,
可以访问文件系统。
我已经在 Ubuntu 中使用 CodeSourcery Lite 4.7.3 环境交叉编译了很长一段时间,并且正在过渡到基于 windows 的环境。我正在使用相同版本的 CodeSourcery, and using "GNU ARM Eclipse Build Tools 进行构建。”出于某种原因,当我在 windows 系统中构建 Ubuntu 中的项目时,当我将它们放在目标上时,它正在 ARM9/ 目录中搜索我构建的自定义共享库。
为了帮助理解运行时错误,我正在编译的是一个需要共享库的动态加载库。 "targetapp" 是预编译的,只有在 windows 环境中交叉编译 "dynamic_module" 时才会出现此错误(是的,我在 [=77] 中使用相同的编译命令=],linux,我只是更新了 eclipse 项目中的交叉编译器路径。
[root@(none) root]# ./targetapp | grep dynamic_module
Error opening dll '/home/root/dynamic_module': ARM9/libSharedLibrary.so: cannot open shared object file: No such file or directory
目标是带有 busybox 的精简定制香草 linux 系统。我只是无法理解为什么这个相对路径被嵌入到我在 Windows 中编译的库中,而不是在 Ubuntu.
中下面是 Ubuntu 交叉编译器和 Windows 交叉编译器的编译器版本输出。
Ubuntu G++ -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure
-v
--with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++
--prefix=/usr
--program-suffix=-4.7
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.7.3
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-gnu-unique-object
--disable-libmudflap
--disable-libitm
--enable-plugin
--with-system-zlib
--enable-objc-gc
--with-cloog
--enable-cloog-backend=ppl
--disable-cloog-version-check
--disable-ppl-version-check
--enable-multiarch
--enable-multilib
--disable-sjlj-exceptions
--with-arch=armv5t
--with-float=soft
--disable-werror
--enable-checking=release
--build=i686-linux-gnu
--host=i686-linux-gnu
--target=arm-linux-gnueabi
--program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1)
Windows G++ -v
Using built-in specs.
COLLECT_GCC=arm-none-linux-gnueabi-g++.exe
COLLECT_LTO_WRAPPER=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.7.3/lto-wrapper.exe
Target: arm-none-linux-gnueabi
Configured with: /scratch/jbrown/2013.05-arm-linux-release/src/gcc-4.7-2013.05/configure
--build=i686-pc-linux-gnu
--host=i686-mingw32
--target=arm-none-linux-gnueabi
--enable-threads
--disable-libmudflap
--disable-libssp
--disable-libstdcxx-pch
--enable-extra-sgxxlite-multilibs
--with-arch=armv5te
--with-gnu-as
--with-gnu-ld
--with-specs='%{save-temps: -fverbose-asm}
%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}
-D__CS_SOURCERYGXX_MAJ__=2013
-D__CS_SOURCERYGXX_MIN__=5
-D__CS_SOURCERYGXX_REV__=24
%{O2:%{!fno-remove-local-statics: -fremove-local-statics}}
%{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}'
--enable-languages=c,c++
--enable-shared
--enable-lto
--enable-symvers=gnu
--enable-__cxa_atexit
--with-pkgversion='Sourcery CodeBench Lite 2013.05-24'
--with-bugurl=https://sourcery.mentor.com/GNUToolchain/
--disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/jbrown/2013.05-arm-linux-release/install/host-i686-mingw32/arm-none-linux-gnueabi/libc
--with-libiconv-prefix=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-gmp=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-mpfr=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-mpc=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-ppl=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic
-lm'
--with-cloog=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--with-libelf=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-mingw32/usr
--disable-libgomp
--disable-libitm
--enable-poison-system-directories
--with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/obj/tools-i686-pc-linux-gnu-2013.05-24-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
--with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/obj/tools-i686-pc-linux-gnu-2013.05-24-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-24)
编辑
我一直在为此苦苦挣扎。它最初是在 windows 中使用 CMake 进行编译时出现的问题,CMake 脚本是由其他人构建的,但我拥有 "dynamic module" 和 "libSharedLibrary.so." "libSharedLibrary.so" 是已知的在架构上工作,并加载到“/usr/lib”以在目标上共享 linking。我首先使用标准 makefile 在 Ubuntu 下编译了 "dynamic_module",然后在 Windows 中尝试使用 CMake,在 Windows 中尝试使用标准 makefile,每个结果都相同。 CMake 脚本最初引用了 "ARM9" 路径,我怀疑它弄乱了我的环境变量或我的交叉环境的其他潜在组件。今天早上我将所有 "ARM9" 引用更改为 "ARM7",并且仍然将相同的相对路径转储到 "dynamic_module." 我可以使用以下命令检查 link 路径...
C:\Raw_SVN\dynamic_module>"C:\ARM_Cross\bin\arm-none-linux-gnueabi-readelf.exe" -a ARM7\dynamic_module | findstr "Shared l
ibrary:"
Type: DYN (Shared object file)
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libarmadillo.so.4]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libboost_serialization.so.1.55.0]
0x00000001 (NEEDED) Shared library: [libboost_date_time.so.1.55.0]
0x00000001 (NEEDED) Shared library: [ARM9/libSharedLibrary.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
我还得到了详细的 linker 命令,如下所示....
C:/ARM_Cross/bin/arm-none-linux-gnueabi-g++.exe
-v
-fPIC
-isystem C:/ARM_Cross/arm-none-linux-gnueabi/libc/include
-isystem C:/ARM_Cross/arm-none-linux-gnueabi/usr/include
-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib
-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib
-shared
-Wl,-soname,ARM7/libDynamic_Module.so
-o
ARM7/libDynamic_Module.so
"CMakeFiles/Dynamic_Module.dir/Dynamic_Module.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp1.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp2.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp3.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp4.cpp.o"
"CMakeFiles/Dynamic_Module.dir/InternalComponents/comp5.cpp.o"
-llapack
-lf2c
-lblas
-lrt
-larmadillo
-lpthread
-lexpat
-lboost_serialization
-lboost_date_time
-lSharedLibrary
Using built-in specs.
COLLECT_GCC=C:/ARM_Cross/bin/arm-none-linux-gnueabi-g++.exe
COLLECT_LTO_WRAPPER=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/lto-wrapper.exe
Target: arm-none-linux-gnueabi
Configured with: /scratch/janisjo/arm-linux-lite/src/gcc-4.5-2011.03/configure
--build=i686-pc-linux-gnu
--host=i686-mingw32
--target=arm-none-linux-gnueabi
--enable-threads
--disable-libmudflap
--disable-libssp
--disable-libstdcxx-pch
--enable-extra-sgxxlite-multilibs
--with-arch=armv5te
--with-gnu-as
--with-gnu-ld
--with-specs='%{save-temps: -fverbose-asm}
%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}
-D__CS_SOURCERYGXX_MAJ__=2011
-D__CS_SOURCERYGXX_MIN__=3
-D__CS_SOURCERYGXX_REV__=41
%{O2:%{!fno-remove-local-statics: -fremove-local-statics}}
%{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}'
--enable-languages=c,c++
--enable-shared
--enable-lto
--enable-symvers=gnu
--enable-__cxa_atexit
--with-pkgversion='Sourcery
G++ Lite 2011.03-41'
--with-bugurl=https://support.codesourcery.com/GNUToolchain/
--disable-nls
--prefix=/opt/codesourcery
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc
--with-build-sysroot=/scratch/janisjo/arm-linux-lite/install/host-i686-mingw32/arm-none-linux-gnueabi/libc
--with-libiconv-prefix=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-gmp=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-mpfr=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-mpc=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-ppl=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic
-lm'
--with-cloog=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--with-libelf=/scratch/janisjo/arm-linux-lite/obj/host-libs-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/usr
--disable-libgomp
--enable-poison-system-directories
--with-build-time-tools=/scratch/janisjo/arm-linux-lite/obj/tools-i686-pc-linux-gnu-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
--with-build-time-tools=/scratch/janisjo/arm-linux-lite/obj/tools-i686-pc-linux-gnu-2011.03-41-arm-none-linux-gnueabi-i686-mingw32/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41)
COMPILER_PATH=c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/;c:/arm_cross/bin/../libexec/gcc/;c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/bin/
LIBRARY_PATH=c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/;c:/arm_cross/bin/../lib/gcc/;c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/lib/;c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/lib/;c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/
COLLECT_GCC_OPTIONS='-v'
'-fPIC'
'-isystem'
'C:/ARM_Cross/arm-none-linux-gnueabi/libc/include'
'-isystem'
'C:/ARM_Cross/arm-none-linux-gnueabi/usr/include'
'-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib'
'-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib'
'-shared'
'-o'
'ARM7/libDynamic_Module.so'
'-shared-libgcc'
'-march=armv5te'
'-funwind-tables'
'-D__CS_SOURCERYGXX_MAJ__=2011'
'-D__CS_SOURCERYGXX_MIN__=3'
'-D__CS_SOURCERYGXX_REV__=41'
c:/arm_cross/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.2/collect2.exe
--sysroot=c:\arm_cross\bin\../arm-none-linux-gnueabi/libc
--eh-frame-hdr
-shared
-dynamic-linker /lib/ld-linux.so.3
-X
-m armelf_linux_eabi
-o ARM7/libDynamic_Module.so c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/crti.o c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/crtbeginS.o
-LC:/ARM_Cross/arm-none-linux-gnueabi/libc/usr/lib
-LC:/ARM_Cross/arm-none-linux-gnueabi/usr/lib
-Lc:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2
-Lc:/arm_cross/bin/../lib/gcc
-Lc:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/../../../../arm-none-linux-gnueabi/lib
-Lc:/arm_cross/bin/../arm-none-linux-gnueabi/libc/lib
-Lc:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib
-soname
ARM7/libDynamic_Module.so
CMakeFiles/Dynamic_Module.dir/Dynamic_Module.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp1.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp2.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp3.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp4.cpp.o
CMakeFiles/Dynamic_Module.dir/InternalComponents/comp5.cpp.o
-llapack
-lf2c
-lblas
-lrt
-larmadillo
-lpthread
-lexpat
-lboost_serialization
-lboost_date_time
-lSharedLibrary
-lstdc++
-lm
-lgcc_s
-lc
-lgcc_s
c:/arm_cross/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/crtendS.o
c:/arm_cross/bin/../arm-none-linux-gnueabi/libc/usr/lib/crtn.o
make[2]: Leaving directory 'C:/Raw_SVN/Dynamic_Module'
在修改环境(cmake配置引用ARM7)的情况下,我无处可以找到这个神秘的link到"ARM9"。如评论所述,问题可能是我的 libSharedLibrary.so 是在 linux 中交叉编译的。我现在要在 Windows 中交叉编译它,看看是否有任何变化。
所以,玩够了,ARM 引用来自我环境中的某个地方,即使它不在 linker 命令中,它也被引入了。其他信息可能是什么告诉 linker 这样做,给定上面参考中发出的命令?
更新
抱歉花了这么长时间才更新这个问题,正如标记的答案中提到的,在我下面的评论中,我能够确定一个解决方案。
在 Whosebug 上找到的Similar SONAME linking problems 帮助我将问题与我在 CMAKE 文件中需要的内容隔离开来。在编译 libSharedLibrary.so 库时,我在 CMakeLists.txt 的最后一行添加了以下内容。
SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY NO_SONAME 1)
如果我没记错的话,这可以防止将 SONAME 嵌入到库中(我相信它包含我神秘的亲戚 ARM9 参考)。如果 libSharedLibrary.so 中没有 SONAME 引用,那么进入 dynamic_module 的 libDynamicLibrary.so link 将使用提供的名称而不是它在其中编译的 SONAME。
再次感谢您的所有帮助,再次感谢 user1034749 让我更接近解决方案。
我在查看您的 link 命令,我想问题出在这里:
-Wl,-soname,ARM7/libDynamic_Module.so
if link 具有此类标志的共享库,然后 link main 用这样的库编程,然后:
evgeniy@localhost /tmp/test $ gcc -shared -o libfoo.so test.o -Wl,-soname,ARM7/libDynamic_Module.so evgeniy@localhost /tmp/test $ gcc -L
pwd
main.c -lfoo evgeniy@localhost /tmp/test $ ./a.out ./a.out: error while loading shared libraries: ARM7/libDynamic_Module.so: cannot open shared object file: No such file or directory
你的问题几乎和你上面描述的一模一样, 为什么ARM9而不是ARM7,可能只能在你这边解决, 可以访问文件系统。