LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-24-2007, 08:56 AM   #1
Dezzroy
LQ Newbie
 
Registered: Sep 2007
Location: Taiwan
Distribution: Ubuntu 7.04
Posts: 4

Rep: Reputation: 0
Did you get gtkmm's hello world tutorial to compile/link? I'm having trouble


Hi,

Using Ubuntu 7.04's Synaptic Package Manager, I got gtkmm-2.4 and its dependencies.

I dowloaded the source files and Makefile for the helloworld program from gtkmm's tutorial section.

If I type "make helloworld", the compiler/linker complains that certain .h files can't be found.

I ran pkg-config, and it seems that it is aware of which directories it should look for the .h files.

If I type "automake",
I get "automake: `configure.ac' or `configure.in' is required"

If I type "automake helloworld",
I get "automake: no Automake input file found for `helloworld'
automake: no input file found among supplied arguments"

gtkmm's site didn't provide a configure.ac or .in file.

Sorry, I am terribly inexperienced with Linux build tools, do you have any advice?
 
Old 09-24-2007, 01:17 PM   #2
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
I have to ask, so I'm sorry if this seems simple, but did you install libgtkmm-2.4-dev? Secondly, have you tried compiling it yourself (may be a problem w/ the Makefile)?
Code:
g++ -o helloworld *.cc `pkg-config gtkmm-2.4 --cflags --libs`
 
Old 09-25-2007, 01:40 AM   #3
Dezzroy
LQ Newbie
 
Registered: Sep 2007
Location: Taiwan
Distribution: Ubuntu 7.04
Posts: 4

Original Poster
Rep: Reputation: 0
Thumbs up

Thanks so much for your response 95se (windows version is your name?)

The included makefile, Makefile.am, has this as its contents:

Code:
include $(top_srcdir)/examples/Makefile.am_fragment

#Build the executable, but don't install it.
noinst_PROGRAMS = helloworld
helloworld_SOURCES = helloworld.h helloworld.cc main.cc
I guess this type of makefile is to be used with automake, but, like I said in my firt post, it doesn't automatically work by merely typing that

After reading some on the web, I got the idea I need a configure.in file. This is what I cobbled together:

Code:
AC_INIT(main.cc)
AM_INIT_AUTOMAKE(helloworld,0.1)
AC_PROG_CXX
AC_OUTPUT(Makefile)
I have no idea if this is correct, and I still get errors with it present.
__________________________
I checked, and Synaptic Package Manager did get libgtkmm-2.4-dev. No need to apologize for asking something simple! These are computers after all, not plugging it into the AC outlet will prevent anything from working, after all
__________________________
When I study the terminal output after running make or g++, I am pretty convinced that the #includes are targetting .h files in the wrong directories.

"/usr/lib/gtkmm-2.4/gtkmm/button.h" is the correct path to "button.h"

in helloworld.h, it has
Code:
#include <gtkmm/button.h>
if I change it to
Code:
#include <gtkmm-2.4/gtkmm/button.h>
the compiler/linker doesn't complain "gtkmm/button.h: No such file or directory"!

I think this is the core problem.

I ran your command line, and this was the first error
Code:
g++: pkg-config gtkmm-2.4 --cflags --libs: No such file or directory
I don't really know what pkg-config does, but I hope it has something to do with telling make/g++ where to look for header files!

(Update as I was typing)

I tried the command line again, having carefully read it again, and I put ` instead of ' around the part with pkg-config, and it worked without any errors or warnings... I saw my first GTK window

I know what g++ does and its basic arguments that it takes, now I am super-interested in this nice little `pkg-config gtkmm-2.4 --cflags --libs` .... please tell me about it!

Thanks, 95se!!
 
Old 09-25-2007, 05:18 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Try running 'autoreconf -if' in the sources, or if there is an autogen.sh file in there run that instead.
 
Old 09-25-2007, 09:32 AM   #5
Dezzroy
LQ Newbie
 
Registered: Sep 2007
Location: Taiwan
Distribution: Ubuntu 7.04
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Try running 'autoreconf -if' in the sources
What would that do?

Sorry, do you mean run it in the directory where the source files are?
 
Old 09-25-2007, 11:15 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Yes, in the sources. That's an autoconf command which recursively runs automake, clocal, autoheader, autoconf, libtoolize, etc, until all the conf files have been updated and renewed. Sometimes source tarballs are not complete or clean for building. It's pretty much a fixall command for any kind of autoconf or automake sources, before running the configure script. If there is an autogen.sh script in the sources it will do much the same, except that it will be only the commands needed and in the right order. These are both useful for sources which are taken from CVS or SVN, or for sources which are very old. For instance, if the developer had used and configure the sources using automake-1.4 and you are running automake-1.9, configuration will usually fail unless you run autoreconf first.

pkg-config is a script based program (part of the GTK2 essentials) which determines where needed header and library files are located on your system. It reads info on available packages from *.pc files installed (usually)to /usr/share/pkgconfig
 
Old 09-26-2007, 09:34 AM   #7
Dezzroy
LQ Newbie
 
Registered: Sep 2007
Location: Taiwan
Distribution: Ubuntu 7.04
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks, gnashley, as I said before, I have a lot to learn about linux build tools.

just a quick question, if I was compiling with multiple libraries, say, gtkmm and boost, would I use a command such as:
Code:
g++ -o helloworld *.cc `pkg-config gtkmm-2.4 <boost package name> --cflags --libs`
?
 
Old 09-26-2007, 09:46 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I think it would be like this:

g++ -o helloworld *.cc `pkg-config gtkmm-2.4 --cflags --libs` `pkg-config boost-package-name --cflags --libs`
 
Old 09-26-2007, 10:10 AM   #9
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Either one will work fine, actually. Order does matter on the gcc (g++) command line, so keep that in mind as well. On Ubuntu, you'll find all your pkg-config files in /usr/lib/pkgconfig/
 
  


Reply

Tags
gtkmm, hello, tutorial, world


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't compile QT tutorial examples Dravis Programming 12 01-13-2008 08:54 PM
Static Link Compile Tutorial firefly2442 Programming 1 12-30-2006 02:35 PM
trouble installing MA111 (following tutorial) pg-savior Linux - Newbie 5 05-25-2006 04:19 PM
C++ tutorial (link) goosie Programming 5 03-12-2006 09:37 AM
sendmail tutorial link shadowsurfer Linux - Newbie 1 04-14-2005 02:57 AM


All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration