接上。
連接器無法識別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位的。