gpt4 book ai didi

c++ - CodeSourcery Lite 强制包含到 ARM9/的搜索路径

转载 作者:太空宇宙 更新时间:2023-11-04 13:02:08 28 4
gpt4 key购买 nike

我已经在 Ubuntu 中使用 CodeSourcery Lite 4.7.3 环境交叉编译了很长一段时间,并且正在过渡到基于 Windows 的环境。我正在使用相同版本的 CodeSourcery 构建,并使用“GNU ARM Eclipse Build Tools”。出于某种原因,当我在我的 Windows 系统中构建我在 Ubuntu 中拥有的项目时,当我将它们放在目标上时,它正在搜索 ARM9/目录以查找我构建的自定义共享库。

为了帮助理解运行时错误,我正在编译的是一个需要共享库的动态加载库。 “targetapp”是预编译的,只有在windows环境下交叉编译“dynamic_module”时才会出现这个错误(是的,我在windows和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 的精简定制 vanilla 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 脚本是由其他人构建的,但我拥有“动态模块”和“libSharedLibrary.so”。已知“libSharedLibrary.so”可在架构上运行,并加载到“/usr/lib”中以在目标上共享链接。我首先使用标准 makefile 在 Ubuntu 下编译了“dynamic_module”,然后尝试在 Windows 中使用 CMake,在 Windows 中尝试使用标准 makefile,每个结果都相同。 CMake 脚本最初引用了“ARM9”路径,我怀疑它弄乱了我的环境变量或交叉环境的其他潜在组件。今天早上我将所有“ARM9”引用更改为“ARM7”,并且仍然有相同的相对路径被转储到“dynamic_module”。我可以使用以下命令检查链接路径...

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]

我还得到了如下所示的详细链接器命令......

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)中,我无法在任何地方找到这个指向“ARM9”的神秘链接。如评论所述,问题可能是我的 libSharedLibrary.so 是在 linux 中交叉编译的。我现在要在 Windows 中交叉编译它,看看是否有任何变化。

所以,玩够了,ARM 引用来 self 环境中的某个地方,即使它不在链接器命令中,它也会被拉入。还有哪些其他信息可以告诉链接器执行此操作,鉴于上述引用中发出的命令?

更新

很抱歉花了这么长时间才更新这个问题,正如标记的答案中所提到的,在我下面的评论中,我能够确定一个解决方案。

Similar SONAME linking problems在 stackoverflow 上找到帮助我将问题隔离到我的 CMAKE 文件中所需的内容。编译 libSharedLibrary.so 库时,我在 CMakeLists.txt 的最后一行添加了以下内容。

SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY NO_SONAME 1)

如果我没记错的话,这可以防止将 SONAME 嵌入到库中(我相信它包含我神秘的亲属 ARM9 引用)。如果 libSharedLibrary.so 中没有 SONAME 引用,则链接到 dynamic_module 的 libDynamicLibrary.so 将使用提供的名称而不是它在其中编译的 SONAME。

再次感谢您的所有帮助,并再次跳转到 user1034749让我更接近解决方案。

最佳答案

我查看了您的链接命令,我想这里有问题:

-Wl,-soname,ARM7/libDynamic_Module.so

如果使用这样的标志链接共享库,然后链接主用这样的库编程,然后:

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,可能只能在你这边解决,可以访问文件系统。

关于c++ - CodeSourcery Lite 强制包含到 ARM9/的搜索路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33611608/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com