Dependencies problem GNU automake

I am using the GNU automake.

I have created the Configure.in and Makefile.am files but don't know how to link in my dependencies.

I have basically added another project (OpenCV) to my eclipse workspace and want to reference this in the build. I have set Eclipse up to include the Cpp files from the new project and this works fine but when I "make" my project it tells me that the files I have referenced from OpenCV are undefined.

The following is the error:

....../TestMain.cpp:14: undefined reference to `cvLoadImage'
....../TestMain.cpp:15: undefined reference to `cvNamedWindow'
....../TestMain.cpp:16: undefined reference to `cvShowImage'
....../TestMain.cpp:17: undefined reference to `cvWaitKey'
....../TestMain.cpp:18: undefined reference to `cvReleaseImage'
....../TestMain.cpp:19: undefined reference to `cvDestroyWindow'

The following is from the Configure.in file:

AC_INIT(TestMain.cpp)
AM_INIT_AUTOMAKE(TestMain, 1.0)
AM_CONFIG_HEADER(config.h:config.in)
AC_PROG_CC
AC_PROG_CXX
AC_OUTPUT(Makefile)

The following is from the Makefile.am file:

bin_PROGRAMS = TestMain
INCLUDES = $(DEPS_CFLAGS)
LDADD = $(DEPS_LIBS)
TestMain_SOURCES = TestMain.cpp

How do I reference the other projects files?

Any help would be appreciated

Thanks
Bret

That would be your main problem.

Eclipse would perhaps be your second. Makefiles really aren't all that hard to write at all. Why burden yourself with crappy autogenerated makefiles and a heavy Java IDE?

Is it actually building them, though?

I just plain never used GNU automake because it was a pain. Now I know why :slight_smile:

Unfortunately, I have always had someone else to do the make files for my previous projects so I don't know how to create one for myself. That's why I thought the GNU tool would be ideal - it looks to me I just have to add a couple of parameters and the rest is done for me.

That was my intention when I used to use kdevelop, but it turns out that automake was finicky, impenetrable, slow(most projects can be compiled in their entirety several times over in the time configure spends checking the same things it checked the last 9000 times it ran), gigantic(probably larger than your project by a factor of ten or more), too often broke down for no good reason, inflexible(uh-oh, I need to add a new library -- time to regenerate my project from scratch!)... automake's next version upgrade obliterated all my projects when their scripts broke compatibility, forcing me to either recreate everything from scratch or just buckle down and learn makefiles already.

Makefiles turned out to be easy. autoconf just makes them look hard because it's so enormous and takes so many steps and spews so much clutter to do so little.

All a makefile does, is describe what files to turn into what files. It already has built-in rules to do most of what else you need. Here's a short example makefile that can transform a.cpp through f.cpp into 'executable' just by running 'make'.

# This file must be named Makefile and placed in the same dir as a.cpp through f.cpp

# The list of object files.  We don't need to tell it a.cpp, since
# make knows .o can be made from .c or .cpp and will search for it.
OBJS=a.o b.o c.o d.o e.o f.o

# Compiler flags go here.
CFLAGS=
# C++ specific compiler flags go here.  CFLAGS gets copied in.
CXXFLAGS=$(CFLAGS)
# Linker flags go here.  For example, let's link in the math library.
LDFLAGS=-lm

# Here we tell make that it needs a.o through f.o to build 'executable'.
# If it doesn't find them, it will build them.
# Note that there is a TAB in front of g++, not eight spaces.
executable:$(OBJS)
        g++ $(OBJS) $(LDFLAGS) -o executable
# Running 'make clean' will cause it to delete the objects and executable.
clean:
        rm -f $(OBJS) executable

Thanks for the info it helped heaps and has got me going.