2012-04-02 10 views
0

C++プログラムをコンパイルしようとすると、未定義の参照エラーが発生する。私はlibと私のコマンドをファイル含めるように指すように-I-Lスイッチを使用しています:C++アプリケーションをコンパイルするときに未定義の参照エラーが発生する

g++ -g -Wall -L/usr/local/lib/active -I/usr/local/include/active tutorial_01.cpp -o tutorial_01 

は、いくつかは、私が欠けている何で私を助けることができますか?あなたはまた、ライブラリーの名前で-lを使用しない限り

In file included from /usr/local/include/active/jaus/core/header.h:44:0, 
       from /usr/local/include/active/jaus/core/message.h:49, 
       from /usr/local/include/active/jaus/core/service.h:44, 
       from /usr/local/include/active/jaus/core/transport/transport.h:44, 
       from /usr/local/include/active/jaus/core/component.h:43, 
       from tutorial_01.cpp:42: 
/usr/local/include/active/jaus/core/address.h: In static member function ‘static bool JAUS::Address::IsReservedComponentID(JAUS::Byte)’: 
/usr/local/include/active/jaus/core/address.h:302:40: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] 
/usr/local/include/active/jaus/core/address.h:303:40: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] 
/tmp/cczAJw8H.o: In function `main': 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:58: undefined reference to `JAUS::Component::Component()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:78: undefined reference to `JAUS::Discovery::Name' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:78: undefined reference to `JAUS::Component::GetService(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:88: undefined reference to `JAUS::Discovery::SetSubsystemIdentification(JAUS::Subsystem::Type, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:100: undefined reference to `JAUS::Component::Initialize(JAUS::Address const&, double)' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:109: undefined reference to `CxUtils::Time::GetUtcTimeMs()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:122: undefined reference to `JAUS::Management::Name' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:122: undefined reference to `JAUS::Component::GetService(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:130: undefined reference to `CxUtils::Time::GetUtcTimeMs()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:136: undefined reference to `CxUtils::Time::GetUtcTimeMs()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:139: undefined reference to `CxUtils::GetChar()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:144: undefined reference to `CxUtils::SleepMs(unsigned int)' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:150: undefined reference to `JAUS::Component::Shutdown()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:58: undefined reference to `JAUS::Component::~Component()' 
/home/reese/JAUS++-2.110519-src/libraries/jaus++/2.0/src/jaus/core/tutorial_01.cpp:58: undefined reference to `JAUS::Component::~Component()' 
collect2: ld returned 1 exit status 
+1

エラーメッセージを投稿してください。 –

+0

エラーメッセージを追加する方法がわかりません。元の質問を修正することはできますか? –

+0

確かに!一番下の「編集」リンクをクリックするだけです。 –

答えて

1

-Lオプションは本当にあなたのために何もしていません。私はあなたがこれをしたいでしょう。その場合には、あなたのライブラリがlibactive.a命名されていることを推測し、取るつもりです:

g++ -g -Wall -L/usr/local/lib/active -lactive -I/usr/local/include/active tutorial_01.cpp -o tutorial_01 

ライブラリは別の名前を持っている場合、あなたはそれを変更する必要があります。

ここにルールがあります:/path/to/library/libmylibrary.aというライブラリの場合は、このコマンドラインを使用してください:-L/path/to/library -lmylibrary

+0

usr/local/lib/activeディレクトリに複数の共有ライブラリがあります。その理由は-L –

+0

です。ディレクトリごとに '-L'を、ライブラリごとに' -l'を使う必要があります。 '-L'はコンパイラが検索するディレクトリを指定しますが、' -l'でライブラリの名前を指定しない限り、実際には検索しません。 – parkovski

+0

ありがとう!私は試してみる –

関連する問題