[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: trauma spliting source into multiple files and applying autotools
- From: Braden McDaniel <braden endoframe com>
- To: gtk-app-devel-list gnome org
- Subject: Re: trauma spliting source into multiple files and applying autotools
- Date: Mon, 20 Jul 2009 12:17:32 -0400
On Mon, 2009-07-20 at 11:22 +1000, Mick wrote:
[snip]
> compiling with:
> gcc -Wall -g -o tutor main.c -export-dynamic `pkg-config --cflags
> --libs gtk+-2.0` produces an executable that runs just as expected.
>
> When I split the .c file into the main function as main.c and the
> 'callbacks' into callback.c and create the Makefile.am, configure.in,
> etc compilation runs without error and the exec runs but hangs after
> displaying: Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET
> (widget)' failed
>
> on:
> gtk_widget_show(chat_window);
You need to add -export-dynamic to AM_LDFLAGS in Makefile.am.
A few more notes...
> configure.in
The filename "configure.ac" is preferred for modern autoconf.
> <code>
> AC_PREREQ([2.63])
> AC_INIT([nuchimp], [0.1], [cheifchimp myemail])
> AM_INIT_AUTOMAKE([nuchimp], [0.1])
This is the old-style invocation of AM_INIT_AUTOMAKE. You don't need
any arguments here. (You can provide a list of options as the argument
instead; see the manual for details.)
> AC_PREFIX_DEFAULT([$HOME])
> AC_CONFIG_SRCDIR([config.h.in])
> AC_CONFIG_HEADERS([config.h])
>
> # Checks for programs.
> AC_PROG_CC
> GTK_CFLAGS="$GTK_CFLAGS `pkg-config --cflags --libs gtk+-2.0`
> -export-dynamic" CFLAGS=" -g -O2"
FYI, your use of -export-dynamic isn't getting applied because it winds
up in INCLUDES, which are C preprocessor flags and thus not applied
during linking. (Or maybe it's getting overwritten by your subsequent
use of AM_PATH_GTK_2_0 before that can happen.)
> # Checks for libraries.
> AM_PATH_GTK_2_0(2.2.0,,AC_MSG_ERROR(BUMMER, I needs GTK+ 2.2.0))
Use PKG_CHECK_MODULES instead of this macro. See "man pkg-config" for
more information; but this should be sufficient:
PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.2])
And you don't need to set GTK_CFLAGS explicitly.
> # Checks for header files.
>
> # Checks for typedefs, structures, and compiler characteristics.
>
> # Checks for library functions.
>
> AC_CONFIG_FILES([Makefile
> src/Makefile])
> AC_OUTPUT
> </code>
>
> Makefile.am
> <code>
> ## Process this file with automake to produce Makefile.in
>
> bin_PROGRAMS = nuchimp
>
> nuchimp_SOURCES = \
> callback.c callback.h \
> main.c main.h
>
> INCLUDES = @GTK_CFLAGS@
INCLUDES has been deprecated in favor of AM_CPPFLAGS.
Also, you should generally prefer using the make variable rather than
using the autoconf substitution directly (i.e., "$(GTK_CFLAGS)" instead
of "@GTK_CFLAGS@"). The advantage of the former is that it can be
overridden at make time (should that be convenient or necessary).
> LDADD = @GTK_LIBS@
You should use AM_LDFLAGS for this instead of LDADD.
> CLEANFILES = *~
As a matter of practice, I advise against having "make clean" remove
files that are not the product of a make invocation.
> DISTCLEANFILES = .deps/*.P
I don't know why this would be necessary.
--
Braden McDaniel <braden endoframe com>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]