Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 273261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:25:51+00:00 2026-05-12T00:25:51+00:00

UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:

  • 0

UPDATE: First problem solved, second one described at the bottom of this post.

UPDATE2: Second problem solved as well.

I’m trying to learn about setting up GNU build tools (autoconf/automake) for a very simple GTK+2 C application. I’ve followed this tutorial and this one that deals with sub directories, but I’m running into a problem where my source directory (in the src sub-directory) is not generating a Makefile, though the parent directory’s Makefile is getting generated.

First, here is my folder structure:

app/src
  - main.c
  - main.h
  - Makefile.am
app
  - configure.ac
  - Makefile.am
  - aclocal.m4
  (... other generated files ...)

Here are the contents of the important files:

app/configure.ac:

AC_PREREQ([2.63])
AC_INIT(app, 0.1)
AM_INIT_AUTOMAKE(app, 0.1)
AC_CONFIG_SRCDIR([src/main.h])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_CONFIG_FILES([Makefile], [src/Makefile])
AC_OUTPUT

app/Makefile.am:

SUBDIRS = src

app/src/Makefile.am:

bin_PROGRAMS = app

app_SOURCES = main.c
app_LDADD = `pkg-config --cflags --libs gtk+-2.0`

Here is what happens when I run the following commands:

$ autoconf
$ automake -a
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... none
configure: creating ./config.status
config.status: creating Makefile
./config.status: line 1153: src/Makefile: No such file or directory
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

When I check, the main app folder gets a Makefile and Makefile.in, but the src folder still only has the Makefile.am. Any ideas?

UPDATE: I made the changes mentioned by adl, namely, I removed the square brackets and comma from the AC_CONFIG_FILES command and removed the app name/version from the AM_INIT_AUTOMAKE command. I also changed the app_LDADD command in src/Makefile.am to app_LDFLAGS. This has fixed my initial problem of not getting through a configure, but now it isn’t looking for the gtk libraries. When I do a make I get something like the following:

$ make
make  all-recursive
make[1]: Entering directory `/home/adam/Development/app-0.1'
Making all in src
make[2]: Entering directory `/home/adam/Development/app-0.1/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" \
      -c -o main.o `test -f 'main.c' || echo './'`main.c; \
    then mv -f ".deps/main.Tpo" ".deps/main.Po"; \
    else rm -f ".deps/main.Tpo"; exit 1; \
    fi
main.c:3:21: error: gtk/gtk.h: No such file or directory
In file included from main.c:4:
main.h:4: error: expected specifier-qualifier-list before ‘GtkWidget’

Here is what I get with pkg-config:

$ pkg-config --libs --cflags gtk+-2.0
-D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

I’m pretty sure I’m doing something wrong in my src/Makefile.am, but I don’t know what. If it helps, my configure script does not appear to be looking for any gtk libs.

UPDATE2:

So the basic solution for the problem in update1 seems to be that I needed to add the following check to my configure.ac file:

PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.12])

PACKAGE_CFLAGS="-g -Wall $GTK_CFLAGS"
PACKAGE_LIBS="-g $GTK_LIBS"
PACKAGE_LDFLAGS="-export-dynamic $GTK_LDFLAGS"

AC_SUBST([PACKAGE_CFLAGS])
AC_SUBST([PACKAGE_LIBS])
AC_SUBST([PACKAGE_LDFLAGS])

This gets added to the checks for programs section under AC_PROG_CC. What this does is tell configure to check for the gtk+-2.0 library. The upper case GTK seems to be an arbitrary variable name, and the CFLAGS, LIBS, and LDFLAGS (and probably more) gets added to it dynamically so that you can generate the PACKAGE_* variables. The AC_SUBST seems to make it so you can access the PACKAGE* variables in your Makefile.am’s. FYI, the -export-dynamic flag is added so that you can use glade/gtkbuilder files (I’m sure there are other reasons, but I’m still at a very basic level of understanding).

In src/Makefile.am, you should have:

bin_PROGRAMS = app

app_SOURCES = main.c main.h 
app_LDADD = @PACKAGE_LIBS@
app_LDFLAGS = @PACKAGE_LDFLAGS@
INCLUDES = @PACKAGE_CFLAGS@

This seems to be all you need for a basic gtk+-2.0 C app. It has actually inspired me to write a simple tutorial for setting up a C gtk app that uses autotools. There is a definite lack of recent beginner documentation/information in this field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:25:51+00:00Added an answer on May 12, 2026 at 12:25 am

    Two issues in your configure.ac file. First, the syntax of your AM_INIT_AUTOMAKE invocation is 10 year old, I suspect you copied it from a very old tutorial (hint: the Automake manual has a tutorialish introduction). You’ve already passed the package and version to AC_INIT, there is no need to repeat that in AM_INIT_AUTOMAKE. Second, the list of files passed to AC_CONFIG_OUTPUT should be a space-separated list given as first argument.

    In other words, your configure.ac should look like

    AC_PREREQ([2.63])
    AC_INIT([app], [0.1], [your@email])
    AM_INIT_AUTOMAKE([-Wall])
    AC_CONFIG_SRCDIR([src/main.h])
    AC_CONFIG_HEADERS([config.h])
    AC_PROG_CC
    AC_CONFIG_FILES([Makefile src/Makefile])
    AC_OUTPUT
    

    Note there is no coma on the AC_CONFIG_FILES line.

    The -Wall option will cause automake to output more warnings (this really is an automake option, not a gcc option), it’s probably safer if you discover these tools.

    This should fix your configure problem. Then I suspect you’ll probably have to split your app_LDADD line into app_CPPFLAGS and app_LDFLAGS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 156k
  • Answers 156k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yeah, using regexes was my gut reaction too, but with… May 12, 2026 at 10:56 am
  • Editorial Team
    Editorial Team added an answer You've asked for the id element, but you want the… May 12, 2026 at 10:56 am
  • Editorial Team
    Editorial Team added an answer Just to confirm, your problem is that functions arranged like… May 12, 2026 at 10:56 am

Related Questions

I have a SQLite database that contains a huge set of log messages. I
I'm writing a C parser using PLY, and recently ran into a problem. This
I have a script in MySQL that creates two tables, the second table references
I am having problems with the greps in Emacs. a) grep doesnt seem to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.