差異處
這裏顯示兩個版本的差異處。
cpp:dll:linux:programmingoneclipse [2013/04/19 18:25] tony 建立 |
cpp:dll:linux:programmingoneclipse [2023/06/25 09:48] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | {{tag> cpp,dll,eclipse}} | ||
- | ====== Programming on Eclipse ====== | ||
- | ===== Compile Problem ===== | ||
- | ==== could not read symbols ==== | ||
- | 在剛建立完shared或static lib的專案第一次編譯時,都會出現如下方的錯誤: | ||
- | <code> | ||
- | Building target: libSharedLibParc.so | ||
- | Invoking: GCC C++ Linker | ||
- | g++ -shared -o"libSharedLibParc.so" ./DiskInfo.o | ||
- | /usr/bin/ld: ./DiskInfo.o: relocation R_X86_64_32S against `vtable for DiskInfo' | ||
- | can not be used when making a shared object; recompile with -fPIC | ||
- | ./DiskInfo.o: could not read symbols: Bad value | ||
- | collect2: ld returned 1 exit status | ||
- | make: *** [libSharedLibParc.so] Error 1 | ||
- | </code> | ||
- | 其實參考它給與的錯誤訊息,將-fPIC加在GCC C++/C Compiler的Miscellaneous中就可以編過了。\\ | ||
- | {{:cpp:dll:linux:eclipse_cpp_build_setting_fpic.png|}}\\ | ||
- | -fPIC(position independent code)用途可以參考[[http://bbs.chinaunix.net/thread-4063737-1-1.html|link]]。 | ||
- | |||