Relocations in generic ELF (EM: 40)

青春壹個敷衍的年華 提交于 2020-05-01 21:20:26

最近在搞机器上的wifi热点,需要移植一大堆东西,如hostapd\wpa_suppliant、dhcp等,这些玩意又依赖其他的一大堆库的移植,比如libnl,openssl等,今天在移植编译libnl-3.4.0出现报错“Relocations in generic ELF (EM: 40)”

详细log如下:

void@void-ThinkPad-E450:~$ tar -xvf libnl-3.4.0.tar.gz
void@void-ThinkPad-E450:~/libnl-3.4.0$ sudo mkdir /usr/local/arm/libnl3.4
void@void-ThinkPad-E450:~$ cd libnl-3.4.0/
void@void-ThinkPad-E450:~/libnl-3.4.0$ ./configure --host=arm-linux –prefix=/usr/local/arm/libnl3.4
void@void-ThinkPad-E450:~/libnl-3.4.0$ sudo make CC=/usr/local/arm/gcc-linaro/bin/arm-linux-gnueabi-gcc
  CC       lib/lib_libnl_3_la-addr.lo
  CC       lib/lib_libnl_3_la-attr.lo
  CC       lib/lib_libnl_3_la-cache.lo
  CC       lib/lib_libnl_3_la-cache_mngr.lo
  CC       lib/lib_libnl_3_la-cache_mngt.lo
  CC       lib/lib_libnl_3_la-data.lo
  CC       lib/lib_libnl_3_la-error.lo
  CC       lib/lib_libnl_3_la-handlers.lo
  CC       lib/lib_libnl_3_la-msg.lo
  CC       lib/lib_libnl_3_la-nl.lo
  CC       lib/lib_libnl_3_la-object.lo
  CC       lib/lib_libnl_3_la-socket.lo
  CC       lib/lib_libnl_3_la-utils.lo
  CC       lib/lib_libnl_3_la-version.lo
  CC       lib/lib_libnl_3_la-hash.lo
  CC       lib/lib_libnl_3_la-hashtable.lo
  CC       lib/lib_libnl_3_la-mpls.lo
  CCLD     lib/libnl-3.la
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: lib/.libs/lib_libnl_3_la-addr.o: Relocations in generic ELF (EM: 40)
lib/.libs/lib_libnl_3_la-addr.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make: *** [lib/libnl-3.la] Error 1

经过查找资料,了解到应该是前后编译器不一样导致,因为在未设置交叉编译器之前我make过一次,失败之后再去配置的,所以只需要clean干净,然后统一用新的交叉编译器编译次即可

void@void-ThinkPad-E450:~/libnl-3.4.0$ ./configure --host=arm-linux --prefix=/usr/local/arm/libnl3.4 CC=/usr/local/arm/gcc-linaro/bin/arm-linux-gnueabi-gcc



void@void-ThinkPad-E450:~/libnl-3.4.0$ sudo make


void@void-ThinkPad-E450:~/libnl-3.4.0$ sudo make install
…........................................
Libraries have been installed in:
   /usr/local/arm/libnl3.4/lib/libnl/cli/qdisc
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/arm/libnl3.4/etc/libnl'
 /usr/bin/install -c -m 644 etc/pktloc etc/classid '/usr/local/arm/libnl3.4/etc/libnl'
make[1]: Leaving directory `/home/void/libnl-3.4.0'

如上则已经成功编译安装。

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!