Reputation: 117
I have tried to compile those files by CodeBlocks which i have downloaded from here:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/frame?h=master
When i try to compile it with Code Blocks i get that error:
main.cpp|8|undefined reference to `ExampleWindow::ExampleWindow()'|
But i compile it like that from terminal it works:
g++ main.cc examplewindow.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
Is there any idea how to make Code Blocks compile two source files ?
-------------- Build: Debug in youtube (compiler: GNU GCC Compiler)---------------
g++ -Wall -fexceptions -g -std=gnu++11 -pthread -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/gtk-3.0 -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/atk-1.0 -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/harfbuzz -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -I/usr/include/ -I/usr/lib/x86_64-linux-gnu/ -c /home/bahaa/programming/c++/youtube/main.cpp -o obj/Debug/main.o g++ -o bin/Debug/youtube obj/Debug/main.o -L/usr/lib/mysql -lmysqlclient -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 obj/Debug/main.o: In function
main': /home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::ExampleWindow()' /home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference toExampleWindow::~ExampleWindow()' /home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::~ExampleWindow()' collect2: error: ld returned 1 exit status Process terminated with status 1 (0 minutes, 1 seconds) 3 errors, 0 warnings (0 minutes, 1 seconds)
https://www.youtube.com/watch?v=3v3koVNb7hU&feature=youtu.be
Upvotes: 0
Views: 348
Reputation: 191
The command you put in your terminal looks completely different from the command codeblocks is executing, so the fact that it does something different is logic.
However in the case of a undefined reference
it usually means that you are forgetting an include
somewhere. Where is ExampleWindow
declared/defined? Is it in included in your main
through one of the two includes you are doing?
Upvotes: 0