You are not logged in.
Hi, I've decided to start learning gtkmm so I can write GUIs for my C++ programs and I found this tutorial on Gtkmm version 3.9 (we currently have 3.10 in the arch repos). https://developer.gnome.org/gtkmm-tutor … helloworld
When I couldn't get my own, slightly modified version to compile, I simply copy/pasted their exact code, comments and all, to see if it was a problem with my environment. I used this command to compile: g++ main.cpp -o main
I got this error:
[mainuser@dx4320 gtkmm3_tut]$ g++ main.cpp -o main
In file included from main.cpp:1:0:
helloworld.hpp:4:26: fatal error: gtkmm/button.h: No such file or directory
#include <gtkmm/button.h>
^
compilation terminated.
I've been some answers on Stackoverflow and other forums mention using something with dpkg-config, but I really don't want to have to use Debian just for gtk as I use arch for all of my machines.
Last edited by kg6zvp (2013-11-13 21:25:01)
Offline
Check dependencies.
Most likely
# pacman -S pkg-config
No signature currently stored in profile.
Offline
Thanks. For some reason I thought pkg-config was dpkg-config. Anyway, I've not gotten this error when compiling:
g++ main.cpp -o main `pkg-config gtkmm-3.0 --cflags --libs`
/tmp/ccwO4zCQ.o: In function `main':
main.cpp:(.text+0x65): undefined reference to `HelloWorld::HelloWorld()'
main.cpp:(.text+0x94): undefined reference to `HelloWorld::~HelloWorld()'
main.cpp:(.text+0xde): undefined reference to `HelloWorld::~HelloWorld()'
collect2: error: ld returned 1 exit status
Any ideas why it might compile this way?
Offline
You're just compiling main. You've left out the helloword.cc file.
EDIT: are you trying to compile the program, or just the main object file? If the latter, you need to specify "-o main.o" not "-o main".
Last edited by Trilby (2013-11-12 23:36:36)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for pointing that out. This is the first program I have compiled without an IDE in awhile. I can't believe I missed that!
Offline
No problem, there is a lot to learn when one steps away from the IDEs.
Except for very large projects, I prefer to just put everything on one line: instead of compiling each object file, then linking, gcc can do it all in one go:
gcc -o helloworld main.cpp helloworld.cpp `pkg --cflags --libs onelib twolib threelib`
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline