[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Setup for a project with autotools so resulting executables can see requ
From: |
Jamil Egdemir |
Subject: |
Setup for a project with autotools so resulting executables can see required binary files? |
Date: |
Sat, 14 Mar 2015 12:10:39 -0400 |
Hi Everyone,
I'm using c to work on some code building against allegro and using
autotools to handle the build system. Trouble is the code is trying
to pull in a bitmap and I'm not sure how to handle this properly when
using autotools. (My apologies in advance if this is more of a c
question or I'm posting on the wrong list here.)
The layout of my project:
allegro-learning/
Makefile.am
README
configure.ac
src/
stargate.c
stargate.bmp
The code in stargate.c pulls in the bitmap with:
stargate = load_bitmap("stargate.bmp", NULL);
Contents of allegro-learning/configure.ac:
AC_PREREQ([2.69])
AC_INIT([allegro-learning], [1.0], address@hidden)
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AM_PROG_CC_C_O
PKG_CHECK_MODULES([ALLEGRO], [allegro >= 4.2.3])
AC_CHECK_HEADERS([stdio.h])
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Contents of allegro-learning/Makefile.am:
SUBDIRS = src
dist_doc_DATA = README
Contents of allegro-learning/src/Makefile.am:
bin_PROGRAMS = stargate
stargate_SOURCES = stargate.c
stargate_CFLAGS = $(ALLEGRO_CFLAGS)
stargate_LDFLAGS = $(ALLEGRO_LIBS)
When I use autotools to build and install:
# autoreconf --install
# ./configure --prefix=$HOME/usr
# make
# make install
and run the resulting executable everything segfaults. Cracking it
open with GDB shows the failure is on the line I've highlighted above
that pulls in stargate.bmp.
However, when I just go to allegro-learning/src and just build
directly w/o using autotools:
# cd allegro-learning/src
# gcc `pkg-config allegro --cflags --libs` -o stargate stargate.c
everything works fine. So I believe I haven't setup the project
properly with autotools to install the bitmaps.
What is the right way to do this?
I have consulted the book 'Autotools' by John Calcote:
https://www.safaribooksonline.com/library/view/autotools/9781593272067/
and it looks like installation of jars when using autotools with java
is a similar problem where you have .jar files that must also get
installed and be available for the executing code to see. But his
example is embedded in a much larger project that is difficult for me to
understand.
I've also looked at 'Data files with Automake':
http://autotoolset.sourceforge.net/tutorial.html#Data-files-with-Automake
but I'm still unsure as to how I should modify my project.
Any specific guidance on how to handle situations like this would be
most appreciated.
- Setup for a project with autotools so resulting executables can see required binary files?,
Jamil Egdemir <=