4

Eclipse CDT を使用して gtkmm Simple Exampleをコンパイルしようとしていますが、何らかの理由で機能しません。

これをMandriva LinuxとGCC 4.4.3でコンパイルしています

このエラーが発生します。これはリンク エラーだと思います。

Building target: Test
Invoking: GCC C++ Linker
g++ -L/usr/include/gtkmm-2.4 -o"Test"  ./test.o   
./test.o: In function `main':
test.cpp:(.text+0x39): undefined reference to `Gtk::Main::Main(int&, char**&, bool)'
test.cpp:(.text+0x43): undefined reference to `Gtk::Window::Window(Gtk::WindowType)'
test.cpp:(.text+0x4b): undefined reference to `Gtk::Main::run(Gtk::Window&)'
test.cpp:(.text+0x53): undefined reference to `Gtk::Window::~Window()'
test.cpp:(.text+0x5b): undefined reference to `Gtk::Main::~Main()'
test.cpp:(.text+0x82): undefined reference to `Gtk::Main::~Main()'
test.cpp:(.text+0x95): undefined reference to `Gtk::Window::~Window()'
./test.o: In function `global constructors keyed to main':
test.cpp:(.text+0xaf): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0xbe): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0xd2): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0xe1): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0xf5): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x104): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x118): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x127): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x13b): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x14a): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x15e): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x16d): undefined reference to `Glib::ustring::~ustring()'
test.cpp:(.text+0x181): undefined reference to `Glib::ustring::ustring(char const*)'
test.cpp:(.text+0x190): undefined reference to `Glib::ustring::~ustring()'
collect2: ld returned 1 exit status
make: *** [Test] Error 1

エラーログが長くて申し訳ありませんが、短くする方法がわかりません

4

2 に答える 2

4

プロジェクトプロパティ->C/C++ビルド->設定GCCC++コンパイラ->その他、この文字列pkg-config gtkmm-3.0 --cflags --libsをその他のフラグに追加します。GCC C ++リンカー->その他、この文字列pkg-config gtkmm-3.0 --cflags --libsをリンカーフラグに追加します。gtkmm 2.4を使用している場合は、「gtkmm-3.0」を「gtkmm-2.4」に置き換えてください。

GCC C ++ COMPILER VERBOSE(_V)文字列にチェックマークを付けます。

于 2011-09-11T14:16:25.110 に答える
1

pkg-config gtkmm-2.4 --cflags --libsターミナルでEclipseを実行するときに、リストされているすべてのライブラリを追加する必要があります。私が見つけた限りでは、Eclipse は pkg-config でうまく動作しないため、手動で追加する必要があります。

プロジェクトを右クリック > プロパティ > C/C++ ビルド > 設定

GCC C++ コンパイラの下で、ディレクトリに、実行時にリストされた各ディレクトリを追加します pkg-config gtkmm-2.4 --cflags (ディレクトリのみ、-I と -pthread をドロップします)。

GCC C++ リンカーの下のライブラリで、からすべてを追加します pkg-config --libs (再度、ライブラリを追加し、-l と -pthread をドロップします)。

于 2011-03-21T11:51:31.333 に答える