g++编译问题:skipping incompatible /usr/lib//libboost_system.so when searching for -lboost_system

接上。

 

连接器无法识别libboost_system.so,虽然找到了动态库文件libboost_system.so但不兼容,导致无法完成链接。

这种情况一般都是二进制不兼容(通俗的讲就是,在一台机器(比如32位)上编译得到的so,放在另一台机器(比如64位)上链接)。

 

查看库文件的属性:

chu@:~/SCFF_proj/trunk/example/echo/websvc[06:21:18]$ readelf -h /usr/lib//libboost_thread-mt.so.1.53.0

ELF 头:

  Magic:  7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00 Class: ELF32

  Data:                              2's complement, little endian

  Version:                           1 (current)

  OS/ABI:                            UNIX - GNU

  ABI Version:                       0

  Type:                              DYN (共享目标文件)

  Machine:                           Intel 80386

  Version:                           0x1

  入口点地址:              0x8ee0

  程序头起点:              52 (bytes into file)

  Start of section headers:          83820 (bytes into file)

  标志:             0x0

  本头的大小:       52 (字节)

  程序头大小:       32 (字节)

  Number of program headers:         7

  节头大小:         40 (字节)

  节头数量:         29

  字符串表索引节头: 28

可以看到这个库文件是为32位操作系统编译的。

 

而我的机器是64位的:

chu@:~/SCFF_proj/trunk/example/echo/websvc[06:21:41]$ uname -a

Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

 

总结下原因就是:

在64位的机器上安装了32位的boost库,能编译才怪。。。。(我为什么会干这种事呢~^~)

 

解决办法:

卸载32位的库,重新安装64位的。

你可能感兴趣的:(System)