You are not logged in.

#1 2013-11-12 22:36:02

kg6zvp
Member
Registered: 2013-01-29
Posts: 7

[SOLVED] can't compile gtkmm3 hello world example

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

#2 2013-11-12 22:52:23

shomyo
Member
From: /dev/sda1
Registered: 2009-11-06
Posts: 40
Website

Re: [SOLVED] can't compile gtkmm3 hello world example

Check dependencies.
Most likely
# pacman -S pkg-config


No signature currently stored in profile.

Offline

#3 2013-11-12 23:04:53

kg6zvp
Member
Registered: 2013-01-29
Posts: 7

Re: [SOLVED] can't compile gtkmm3 hello world example

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

#4 2013-11-12 23:35:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,332
Website

Re: [SOLVED] can't compile gtkmm3 hello world example

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

#5 2013-11-12 23:45:28

kg6zvp
Member
Registered: 2013-01-29
Posts: 7

Re: [SOLVED] can't compile gtkmm3 hello world example

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

#6 2013-11-12 23:49:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,332
Website

Re: [SOLVED] can't compile gtkmm3 hello world example

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

Board footer

Powered by FluxBB