作者antirazin (~ SNSD & KARA ~ )
看板MacDev
標題[問題] Xcode開發C++如何連接C++ shared object
時間Tue Feb 6 21:43:12 2018
抱歉小弟是Xcode和C++的新手,初在此板發文,麻煩各位大大鞭小力一點 >"<
我現在手邊有一個.so檔,
透過nm反編譯找到一些function想要使用看看,
我已經在Build Phrases -> Link Binary with Libraries 加入了該so檔,
似乎還是沒辦法讓我的C++ project找到,
我也沒有相關的header檔,
想問看看各位大大的看法~
邏輯上不正確之處請多指正謝謝~!
--
1F:推 waterspout:其中這男子為什麼在對方說不後 仍強行撫摸對方下體10/11 21:45
2F:→ waterspout:而裡面有沒有什麼秘密? 好!我們今天也請到了五位來賓 10/11 21:46
3F:→ e6638:皓平:其實馬雅人早就預言到了 10/11 21:46
4F:→ waterspout:皓平 我還沒叫到你
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.24.189.173
※ 文章網址: https://webptt.com/m.aspx?n=bbs/MacDev/M.1517924606.A.7B2.html
5F:→ XXXXLAY: Pch? 02/07 01:18
6F:→ antirazin: 也沒.pch file 02/07 22:43
7F:推 yume190: 沒header file 嗎? 02/09 12:53
8F:→ yume190: 以及是 run 本機嗎 02/09 12:58
9F:→ yume190: Link flag 有下嗎 02/09 12:59
後來我是找到可以用dlopen和dlsym去動態load shared object,
結果出現error
Cannot load library: dlopen(/usr/lib64/libtest.so, 1): no suitable image found. Did find:
/usr/lib64/libtest.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/usr/lib64/libtest.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
Program ended with exit code: 1
上網參考
https://stackoverflow.com/questions/1924452/what-can-cause-dlopen-no-suitable-image-found-cant-map
看起來是shared object格式Mac OS認不出來,
後來換成用VM去開一個CentOS出來就編的過了,
目前是卡在執行時dlopen會跑出segmentation fault.....
※ 編輯: antirazin (114.24.151.163), 02/12/2018 00:24:24