LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2011, 03:54 PM   #1
chisser98
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Rep: Reputation: Disabled
non-recursive automake issues


Hi everyone,

Right now I'm trying to get my Autotools build to work with non-recursive automake, but I'm not having much luck.

Here's the error I'm getting:

Code:
jarrett@jarrett-Latitude-D520:~/Projects/WeightManager/build$ make
make  all-am
make[1]: Entering directory `/home/jarrett/Projects/WeightManager/build'
depbase=`echo src/view/WMWindow.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
	g++ -DHAVE_CONFIG_H -I. -I..  `wx-config --cxxflags`   -g -O2 -g -O2 -MT src/view/WMWindow.o -MD -MP -MF $depbase.Tpo -c -o src/view/WMWindow.o ../src/view/WMWindow.cpp &&\
	mv -f $depbase.Tpo $depbase.Po
g++  -g -O2 -g -O2   -o WeightManager src/view/WMWindow.o  `wx-config --libs` 
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [WeightManager] Error 1
make[1]: Leaving directory `/home/jarrett/Projects/WeightManager/build'
make: *** [all] Error 2
quick note: the `wx-config --libs` returns the library path and library names required for the linking process using the wxWidgets project...Similarly, `wx-config --cxxflags` returns the include paths needed for compiling the project using the wxWidgets project.

It looks like it's going into the 'src/view/' directory and trying to compile and link whatever is in there as if that is all of the source files for the project. However, there are other source files that need to be compiled, and the 'main' method is defined in 'src/WMMain.h'.

My directory structure looks like this:

.../WeightManager
Makefile.am
configure.ac
autogen.sh
.../WeightManager/src
Common.h
WMMain.h <-- contains the 'main' function
.../WeightManager/src/view
WMWindow.h
WMWindow.cpp
.../WeightManager/src/model
<empty>
.../WeightManager/src/controller
<empty>

Right now, I create a 'build' directory within the WeightManager directory, cd into it, run ../configure and then make.

I had this working with a basic build (i.e. only WMMain.h), but adding the extra 'view' directory has caused problems.

Here's what my Makefile.am looks like:
Code:
# Tell automake to put the object files in the appropriate directories
AUTOMAKE_OPTIONS = subdir-objects

ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

WX_LIBS = `wx-config --libs` 
WX_CPPFLAGS = `wx-config --cxxflags`

AM_CPPFLAGS = $(WX_CPPFLAGS)
LIBS = $(WX_LIBS)

bin_PROGRAMS = WeightManager 

WeightManager_SOURCES = \
	src/WMMain.h \
	src/Common.h \
	src/view/WMWindow.h src/view/WMWindow.cpp

dist_noinst_SCRIPTS = autogen.sh
And here's my configure.ac:
Code:
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([WeightManager],[0.1],[support@jarrettchisholm.com],[WeightManager],[http://www.weightmanager.jarrettchisholm.com/])
AC_CONFIG_AUX_DIR(config)

AC_CANONICAL_HOST

AM_INIT_AUTOMAKE([subdir-objects])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL

# Checks for library functions.



# Check platform
case "$host" in
        *-*-mingw*|*-*-cygwin*)
                AC_DEFINE(PLATFORM_WIN32, 1, [Platform is Win32])
                #opengl_LIBS="-lunsupported_platform"
                PLATFORM_STRING="Win32"
                ;;
        *-*-linux*)
                AC_DEFINE(PLATFORM_LINUX, 1, [Platform is Linux])
                #opengl_LIBS="-lGL -lGLU -lglut"
                PLATFORM_STRING="Linux"
                ;;
        *-*-darwin*)
                AC_DEFINE(PLATFORM_APPLE, 1, [Platform is Apple])
                #opengl_LIBS="-framework AGL -framework OpenGL -framework GLUT"
                PLATFORM_STRING="Apple"
                ;;
        *)
                AC_MSG_WARN([*** Please add $host to configure.ac checks!])
                ;;
esac
#AC_SUBST(opengl_LIBS)



# Check architecture
case "$host" in
        i?86-* | k?-* | athlon-* | pentium*-)
                AC_DEFINE(ARCH_X86, 1, [Architecture is x86])
                ARCH_SPECIFIC_CFLAGS=""
                ARCH_STRING="X86"
                ;;
        x86_64-*)
                AC_DEFINE(ARCH_X86_64, 1, [Architecture is x86-64])
                ARCH_SPECIFIC_CFLAGS="-DUSE_ADDR64"
                ARCH_STRING="X86-64"
                ;;
        ppc-* | powerpc-*)
                AC_DEFINE(ARCH_PPC, 1, [Architecture is PowerPC])
                ARCH_SPECIFIC_CFLAGS=""
                ARCH_STRING="PowerPC"
                ;;
        *)
                AC_MSG_ERROR([Unknown Architecture])
                ;;
esac
AC_C_BIGENDIAN

# Setup configuration header
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
# Configuration switches



# HACK - 	For some reason, wxwin.m4 wasn't installed properly when I installed 
#			wxWidgets-2.8.12.  Therefore, I need to include this file manually to 
#			ensure that the wx specific m4 macros used below are defined.
m4_include(wxwin.m4)

# Check wxWidgets 2.8.x is installed
AM_OPTIONS_WXCONFIG
reqwx=2.8.0
AM_PATH_WXCONFIG($reqwx, wxWin=1)
if test "$wxWin" != 1; then
	AC_MSG_ERROR([
		wxWidgets must be installed on your system.
 
		Please check that wx-config is in path, the directory
		where wxWidgets libraries are installed (returned by
		'wx-config --libs' or 'wx-config --static --libs' command)
		is in LD_LIBRARY_PATH or equivalent variable and
		wxWidgets version is $reqwx or above.
		])
fi


# Check the build mode
AC_ARG_ENABLE([debug],
    [AS_HELP_STRING([--enable-debug],[build with debugging information (default NO)])],
    [], [enable_debug=no])

AC_MSG_CHECKING([build mode])
AS_IF([test $enable_debug = yes], [build_mode=debug], [build_mode=optimize])
AC_MSG_RESULT([$build_mode])



# Set the compiler/linker flags
CXXFLAGS="$ARCH_SPECIFIC_CFLAGS $CXXFLAGS $CFLAGS"
CFLAGS="$ARCH_SPECIFIC_CFLAGS $CFLAGS"
CPPFLAGS="$ARCH_SPECIFIC_CFLAGS $CPPFLAGS"



# Create generated files
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

AC_MSG_NOTICE([

Please type 'make' to build WeightManager
])
Does anyone have any idea why I'm getting the error I'm getting?

I'm at a complete loss.

I appreciate any help you guys and gals can provide!

Thanks

Jarrett
 
Old 10-18-2011, 06:53 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by chisser98 View Post
However, there are other source files that need to be compiled, and the 'main' method is defined in 'src/WMMain.h'.
There is a difference between declaring a function and defining a function. The declaration is the prototype ie int main();, and there can be many copies of it so it is safe to put in an .h file. The definition includes the actual code in the function, ie int main() { ... }, there should be exactly one copy of it so it should NOT go in an .h file because .h files get #included multiple times.

You should have a src/WMMain.c with the definition of main(). You probably don't need a declaration of main() in WMMain.h (but it is not an error to have one) because no other function in your program will be calling main(): it is called by the operating system.
 
Old 10-19-2011, 10:57 AM   #3
chisser98
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hey ntubski,

Thanks for the reply!

I read over your reply a few times, and looked over my code a few times. I realized I didn't have a WMMain.h file, but in fact it actually was a WMMain.cpp file. All I had to do was to change the file name in my Makefile.am from WMMain.h to WMMain.cpp...yeesh!

Thanks for taking the time to reply ntubski, I appreciate it!

Cheers

Jarrett
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cp automake itself LowKey88 *BSD 1 07-14-2009 05:49 PM
autoconf, automake installation issues with ./configure brn_rh Linux - Newbie 1 10-22-2007 05:46 PM
Scribus installation problem, sez I need automake 1.6 when automake 1.9 is istalled Rockgod2099 Linux - Software 13 11-14-2004 06:37 PM
slackware 9 asking for automake 1.6 while i have automake 1.7 gtgoku Slackware 1 10-19-2003 08:59 AM
automake verigoth Programming 0 09-16-2002 12:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration