因為zmq的原生配置rpath和gcc路徑一樣,無法滿足自定義目錄的gcc安裝環境,所以進行修改
1.解壓zmq原始碼,開啟檔案makefile.am,增加-wl,-rpath,'$$origin',如下
if on_linux
libzmq_la_ldflags = \
-version-info @ltver@ \
@libzmq_extra_ldflags@ \
-wl,--version-script=$(srcdir)/src/libzmq.vers -wl,-rpath,'$$origin'
else
2.執行命令autoreconf,重新配置
3.執行編譯功能
./configure --with-libsodium=no && make clean && make
4.檢視rpath
[root@mba zeromq-4.1.4]# readelf -d .libs/libzmq.so
dynamic section at offset 0x5c7a0 contains 27 entries:
tag type name/value
0x0000000000000001 (needed) shared library: [librt.so.1]
0x0000000000000001 (needed) shared library: [libpthread.so.0]
0x0000000000000001 (needed) shared library: [libstdc++.so.6]
0x0000000000000001 (needed) shared library: [libm.so.6]
0x0000000000000001 (needed) shared library: [libc.so.6]
0x0000000000000001 (needed) shared library: [libgcc_s.so.1]
0x000000000000000e (soname) library soname: [libzmq.so.5]
0x000000000000000f (rpath) library rpath: [/usr/local/gcc-5.3.0/lib/../lib64:$origin]
0x000000000000000c (init) 0xb9e0
0x000000000000000d (fini) 0x478a8
0x0000000000000004 (hash) 0x158
0x0000000000000005 (strtab) 0x1790
0x0000000000000006 (symtab) 0x650
0x000000000000000a (strsz) 3781 (bytes)
0x000000000000000b (syment) 24 (bytes)
0x0000000000000003 (pltgot) 0x25ca20
0x0000000000000002 (pltrelsz) 3072 (bytes)
0x0000000000000014 (pltrel) rela
0x0000000000000017 (jmprel) 0xade0
0x0000000000000007 (rela) 0x28d8
0x0000000000000008 (relasz) 34056 (bytes)
0x0000000000000009 (relaent) 24 (bytes)
0x000000006ffffffe (verneed) 0x27c8
0x000000006fffffff (verneednum) 5
0x000000006ffffff0 (versym) 0x2656
0x000000006ffffff9 (relacount) 1334
0x0000000000000000 (null) 0x0
編譯時斷言
執行時斷言大家都用過,但如果想當某個條件不滿足時在編譯時就讓程式編譯不通過,即編譯時斷言 不能產生 是什麼樣子的呢。可參考如下 1,參考linux核心靜態斷言 force a compilation error if condition is true ifdef win32 define buil...
編譯時輸出訊息
define todo message string msg file boost stringize line todo msg function if defined msc ver pragma messages are only supported on msvc.define todo m...
編譯時的 warning
warning其實可以分為兩種 一種是可以忽略的,一種是不可以忽略的。比如 int被看作bool的warning往往是不能忽略的,而myclass 被轉換成int的warning都是可忽略的。pragma warning disable x 可以顯式的忽略那些確定不會造成惡劣影響的warning。比...