2

odbc SDK でいくつかの例をコンパイルするのに問題があります。ライブラリの順序をしばらく検討した後、どうにかして、未定義の参照の数をいくつか取得することができました。

悲しいことに、残りのものを取り除く方法がわかりません。失敗しているコマンドは次のとおりです。

g++ -Wall -z defs -m64 -DSIMBA -D_REENTRANT -fPIC -O0 -g -shared Common/TabbedUnicodeFileReader_Linux_x8664_debug.cpp.o Core/QSConnection_Linux_x8664_debug.cpp.o Core/QSDriver_Linux_x8664_debug.cpp.o Core/QSEnvironment_Linux_x8664_debug.cpp.o Core/QSStatement_Linux_x8664_debug.cpp.o DataEngine/QSDataEngine_Linux_x8664_debug.cpp.o DataEngine/QSMetadataHelper_Linux_x8664_debug.cpp.o DataEngine/QSTable_Linux_x8664_debug.cpp.o DataEngine/QSTableUtilities_Linux_x8664_debug.cpp.o DataEngine/QSTypeInfoMetadataSource_Linux_x8664_debug.cpp.o Common/QSTableMetadataFile_Unix_Linux_x8664_debug.cpp.o Common/QSUtilities_Unix_Linux_x8664_debug.cpp.o Main_Unix_Linux_x8664_debug.cpp.o    -Wl,--no-undefined -Wl,--no-allow-shlib-undefined -Wl,--whole-archive,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaDSI_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaSupport_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libAEProcessor_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libCore_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libDSIExt_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libExecutor_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libParser_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaODBC_debug.a -Wl,--no-whole-archive -Wl,--soname=../Bin/Linux_x8664/libQuickstart_debug.so -L/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//ThirdParty/icu/Linux_x8664/lib -licuuc_simba64 -licudata_simba64 -licui18n_simba64 -lpthread -lm -lc -ldl -Wl,--version-script=exports_Linux.map -o ../Bin/Linux_x8664/libQuickstart_debug.so

編集:記号がありません

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libdl.so: undefined reference to `_dl_rtld_di_serinfo@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_dl_allocate_tls_init@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_stack_end@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_dl_get_tls_static_info@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__tls_get_addr@GLIBC_2.3'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_dl_deallocate_tls@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_dl_allocate_tls@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `_dl_make_stack_executable@GLIBC_PRIVATE'

修理済み:

-Wl,--no-allow-shlib-undefined を削除するとうまくいくようです。ビルドされた共有ライブラリは完全に機能しているようです。

4

4 に答える 4

4

あなたは非常に一般的な初心者の間違いをします。リンクするライブラリは、コマンドラインの途中または先頭に配置します。リンカGCCは、の順序でニーズの依存関係を使用します。つまり、ライブラリLの関数を使用するソース/オブジェクトファイルSがある場合、ファイルAはコマンドラインでライブラリLの前にある必要があります。

つまり、代わりにライブラリ(-lm -lc -ldl)をコマンドラインの最後に配置します。

于 2012-08-07T11:01:28.223 に答える
4

完全に別のアプリケーションでも同様の問題がありました。次のコンパイル時フラグが機能しました。

-B/usr/lib/gold-ld/

私が見つけた:

https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/885927

gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 を使用しています。lto でコンパイルしようとしていました。

于 2012-11-27T15:41:40.103 に答える
2

リンカが参照されているすべてのシンボルを解決できない場合、これは提供されたライブラリの順序が間違っていることが原因である可能性があります。正しい順序がわからない場合は、アーカイブを「--start-group archives --end-group」に配置します。これにより、ldマニュアルによると、リンカーは、新しい未定義の参照が作成されなくなるまで、指定されたアーカイブを繰り返し検索します。ただし、パフォーマンスコストに注意してください。

于 2012-08-07T18:28:59.460 に答える
0

「削除」に言及したOP-Wl,--no-allow-shlib-undefinedが役立ちました。私の場合、反対を追加する必要がありました: -Wl,--allow-shlib-undefined

(古いバージョンの GCC ではすべて正常に動作していました)

于 2022-01-26T16:54:05.200 に答える