LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Did you get gtkmm's hello world tutorial to compile/link? I'm having trouble (https://www.linuxquestions.org/questions/programming-9/did-you-get-gtkmms-hello-world-tutorial-to-compile-link-im-having-trouble-586957/)

Dezzroy 09-24-2007 07:56 AM

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?

95se 09-24-2007 12:17 PM

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`

Dezzroy 09-25-2007 12:40 AM

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 :D
__________________________
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 :cool:

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!!

gnashley 09-25-2007 04:18 AM

Try running 'autoreconf -if' in the sources, or if there is an autogen.sh file in there run that instead.

Dezzroy 09-25-2007 08:32 AM

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?

gnashley 09-25-2007 10:15 AM

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

Dezzroy 09-26-2007 08:34 AM

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`
?

gnashley 09-26-2007 08:46 AM

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`

95se 09-26-2007 09:10 AM

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/


All times are GMT -5. The time now is 05:45 AM.