私のgcc/g ++バージョンはCentOS 5.10で4.1.2、ACE-6.10であり、ACEライブラリをstatic_libs = 1とすると、静的ライブラリを取得します。makeとmake installの後、libACE .so、libACE.a等、及び、私はテストするためのコード次ライト、コードは以下のように示す:私は静的ライブラリを使用してコンパイルとリンクを行いますが、動的ライブラリはAMCEデモで間違っていますか?
#include <ace/Log_Msg.h>
#include <ace/OS_main.h>
using namespace std;
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
ACE_DEBUG((LM_DEBUG, ACE_TEXT("Hello World!\n")));
return 0;
}
、私はコンパイルするには、次の2つの方法を使用してリンク:
方法1 :
g++ -p -o acetest acetest.cpp /usr/local/src/ACE_wrappers/lib/libACE.a -I$ACE_ROOT -I$ACE_ROOT/ace -pthread -ldl -lrt
方法2:
[[email protected] testCode]# g++ -p -o acetest acetest.cpp -L/usr/local/src/ACE_wrappers/lib -lACE -I$ACE_ROOT -I$ACE_ROOT/ace -pthread -ldl -lrt
/tmp/cc0eKwlC.o: In function `main':
acetest.cpp:(.text+0x15): undefined reference to `ACE_Log_Msg::last_error_adapter()'
acetest.cpp:(.text+0x1d): undefined reference to `ACE_Log_Msg::instance()'
acetest.cpp:(.text+0x3f): undefined reference to `ACE_Log_Msg::conditional_set(char const*, int, int, int)'
acetest.cpp:(.text+0x57): undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char const*, ...)'
collect2: ld 返回 1
そして、それが問題になる、静的ライブラリを使用するための方法1は、なぜ動的ライブラリを使用する方法2は、間違っている、correntのですか?
回答のための空腹、ありがとうすべて;アプリケーションをコンパイルするとき
ありがとう、しかし私は方法1の静的ライブラリとリンクする方法は実行可能ファイルを取得するためにcorrentです。私がトラップしている問題は、上記の方法2のようにリンク先が間違っていることを示すダイナミックライブラリを使用する場合です。 –