差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
java:jna:c_so的undefined_symbol問題 [2017/03/16 11:25]
tony [How to resolve?]
java:jna:c_so的undefined_symbol問題 [2023/06/25 09:48] (目前版本)
行 1: 行 1:
 +{{tag>​jna cpp mangling}}
 ====== c++ so的undefined symbol問題 ====== ====== c++ so的undefined symbol問題 ======
 ===== Problem ===== ===== Problem =====
行 52: 行 53:
 為了避免這個問題,我們可以透過在function宣告extern "​C":​ 為了避免這個問題,我們可以透過在function宣告extern "​C":​
 <file cpp test.c> <file cpp test.c>
 +extern "​C"​ int test() 
 +
 +        return 0; 
 +}
 </​file>​ </​file>​
 +此時可以透過nm -D指令去確認編譯出來的so檔,是否保有原本的symbol名稱,與確認JNA已可正常使用。
 ===== Reference ===== ===== Reference =====
   * [[http://​stackoverflow.com/​questions/​31541451/​create-shared-library-from-cpp-files-and-static-library-with-g|Create shared library from cpp files and static library with g++]]   * [[http://​stackoverflow.com/​questions/​31541451/​create-shared-library-from-cpp-files-and-static-library-with-g|Create shared library from cpp files and static library with g++]]