LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   gtkmm makefile (http://www.linuxquestions.org/questions/linux-software-2/gtkmm-makefile-873185/)

mike lear 04-05-2011 03:50 PM

gtkmm makefile
 
I have written and tested several gtkmm app files which I wish to package as a tar.gz distribution. However the Gnu auto-tools package fails to see
my gtkmm-2.4 libraries or headers. It sees the stdc++ libraries ok. I wonder
if anyone else has had this problem. When I run configure it fails to see
gtkmm.h. The output from my configure script give the following:
checking for iostream... yes
checking memory usability... yes
checking memory presence... yes
checking for memory... yes
checking gtkmm.h usability... no
checking gtkmm.h presence... no
checking for gtkmm.h... no
checking gtkmm/main.h usability... no
checking gtkmm/main.h presence... no
checking for gtkmm/main.h... no
I can build the files using pkg-config but this doesn't fix my configuration.ac file problem.
Thanks in advance

ntubski 04-08-2011 04:42 PM

How/where did you install gtkmm? What did you put in configure.ac to check for gktmm?

Quote:

I can build the files using pkg-config but this doesn't fix my configuration.ac file problem.
Have you considered using the pkg-config autoconf macros: The PKG_CHECK_MODULES Macro.

mike lear 04-11-2011 01:57 AM

Regarding the installation of gtkmm I am using Fedora 14 and used the yum package installer to intall gtkmm-2.4 and gtkmm-3.0 with the development libraries for both versions. The yum installer also includes cairo ,pango ect all the dependencies. My
configure.ac file is depicted below.
dnl
AC_PREREQ([2.66])
AC_INIT([Vimake_Gui], [1-18], [mikeofthenight2003@yahoo.com])
AM_INIT_AUTOMAKE([1.11 no-define])
AC_CONFIG_SRCDIR([src/vghelp.cc])
AC_PREFIX_DEFAULT([$HOME])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_LANG_CPLUSPLUS
LDFLAGS=`pkg-config gtkmm-2.4 --libs`
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.4.0])
AC_CHECK_LIB(gtkmm-2.4, _init,,
AC_MSG_ERROR(Essential library libgtkmm-2.4 not found))
AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS)
CPPFLAGS=`pkg-config gtkmm-2.4 --cflags`
AC_CHECK_HEADERS([cstdlib])
AC_CHECK_HEADERS([string])
AC_CHECK_HEADERS([iostream])
AC_CHECK_HEADERS([memory])--
AC_CHECK_HEADERS([vector])
AC_CHECK_HEADERS([gtkmm.h])
AC_CHECK_HEADER([gtkmm/main.h],[AC_DEFINE([HAVE_GTKMM_H], [1],
[Define to 1 if you have <gtkmm/main.h>.])],[AC_MSG_ERROR([sorry, you need to have gtkmm-2.4 installed!])])
AC_HEADER_STDBOOL
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

I am using gtkmm-2.4 as the gtkmm-3.0 version that I have installed fails to build using pkg-config on two different pc's running Fedora 14.
It fails with the same fault on any files I try to build with gtkmm-3.0
command used:
g++ examplewindow.cc examplewindow.cc -o test_example `pkg-config gtkmm-3.0 --cflags --libs`
Error returned:
/usr/include/gtk-3.0/gtk/gtkapplication.h:57:3: error: ‘GApplication’ does not name a type

The comfigure.ac file works only because I have used the pkg-config commands.
Any advice would be appreciated.

mike lear 04-11-2011 07:28 AM

The line in my previous posting read:
g++ examplewindow.cc examplewindow.cc -o test_example `pkg-config gtkmm-3.0 --cflags --libs`
It should have read
g++ examplewindow.cc exampledialog.cc main.cc -o test_example `pkg-config gtkmm-3.0 --cflags --libs`
I was quite sleepy when I posted the earlier question.

ntubski 04-11-2011 09:26 PM

Code:

LDFLAGS=`pkg-config gtkmm-2.4 --libs`
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.4.0])
AC_CHECK_LIB(gtkmm-2.4, _init,,
AC_MSG_ERROR(Essential library libgtkmm-2.4 not found))
AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS)

You don't need the direct call to pkg-config if you are using PKG_CHECK_MODULES, just use GTKMM_CFLAGS and GTKMM_LIBS in your makefile. The manual checks for gtkmm.h and libgtkmm are also redundant.

mike lear 04-12-2011 02:25 AM

If I comment out the direct calls to pkg-config in the configure.ac
dnl LDFLAGS=`pkg-config gtkmm-2.4 --libs`
dnl CPPFLAGS=`pkg-config gtkmm-2.4 --cflags`

My Makedile.am already contains the following
AM_CXXFLAGS = $(GTKMM_CFLAGS)
vgabout_LDADD = $(GTKMM_LIBS)

Running .configure after a autoreconf -if
gives me the following output
....
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTKMM... yes
checking for _init in -lgtkmm-2.4... yes
... // skipping parts of output not relevant
further down...
checking for vector... yes
checking gtkmm.h usability... no
checking gtkmm.h presence... no
checking for gtkmm.h... no
checking gtkmm/main.h usability... no
checking gtkmm/main.h presence... no
checking for gtkmm/main.h... no
configure: error: sorry, you need to have gtkmm-2.4 installed!

Configure now sees the pkg-config and GTKMM yet does not see gtkmm.h
If I uncomment the CXXFLAGS=pkg-config... then re-running the commands it then sees gtkmm.h but when I then run make it fails to see all of the GTKMM library paths and fails during the make with the following:
/usr/bin/ld: note: 'virtual thunk to Atk::Implementor::~Implementor()' is defined in DSO /usr/lib/libatkmm-1.6.so.1 so try adding it to the linker command line
Once I uncomment both direct calls to pkg-config in configure.ac it then configures and builds with no errors.
I am confused am I missing something ?

ntubski 04-12-2011 06:53 AM

If you want the test for gtkmm headers to work in configure then you have to set the CFLAGS in configure:
Code:

PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.4.0])
CFLAGS="$GTKMM_CFLAGS $CFLAGS"
AC_CHECK_LIB(gtkmm-2.4, _init,,
AC_MSG_ERROR(Essential library libgtkmm-2.4 not found))
AC_SUBST(GTKMM_CFLAGS)
AC_SUBST(GTKMM_LIBS)
...
AC_CHECK_HEADERS([gtkmm.h])
AC_CHECK_HEADER([gtkmm/main.h],[AC_DEFINE([HAVE_GTKMM_H], [1],
[Define to 1 if you have <gtkmm/main.h>.])],[AC_MSG_ERROR([sorry, you need to have gtkmm-2.4 installed!])])

But I would suggest removing the manual check for gtkmm headers: it's redundant because PKG_CHECK_MODULES will signal an error if gtkmm is not installed.


Quote:

My Makedile.am already contains the following
AM_CXXFLAGS = $(GTKMM_CFLAGS)
vgabout_LDADD = $(GTKMM_LIBS)
How come you are assigning to AM_CXXFLAGS but vgabout_LDADD?
Quote:

If I uncomment the CXXFLAGS=pkg-config... then re-running the commands it then sees gtkmm.h but when I then run make it fails to see all of the GTKMM library paths
You assigned to LDFLAGS in the direct call, but vgabout_LDADD for the PKG_CHECK_MODULES result, that may explain why it fails to find the libraries.

mike lear 04-13-2011 05:36 AM

I will try the options you suggest I am at work at the present so won't have access to my programs until later.
It seems you have spotted a typeo I have missed over the last week. The word in Makefile.am should have read AM_LDADD and not
vgabout_LDADD. I think I missed it because I have been concentrating on the configure.ac file and not the Makefile, because I
managed to get it to work with the two direct commands to pkg-config I wrongly assumed the Makefile.am was correct and never really checked it.
Thanks I will give it a go later.

mike lear 04-13-2011 11:52 AM

Back home I tried out your suggestions and it now works fine with the following:
In Makefile.am:
AM_CXXFLAGS = $(GTKMM_CFLAGS)
LDADD = $(GTKMM_LIBS)

in configure.ac:
AC_INIT(./src/vgabout.cc)
AC_PREREQ(2.66)
AM_INIT_AUTOMAKE(vimakegui,1.0)
AM_CONFIG_HEADER(config.h)
AC_PROG_CXX
dnl AC_DEFINE(GTKMM)
AC_PREFIX_DEFAULT([$HOME])
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.4.0])
CFLAGS="$GTKMM_CFLAGS $CFLAGS"
AC_CHECK_HEADERS([iostream])
AC_CHECK_HEADERS([memory])
AC_CHECK_HEADERS([vector])
AC_CHECK_HEADERS([gtkmm.h])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

Thanks very much for your assistance and patience. Mike Lear


All times are GMT -5. The time now is 05:31 PM.