Skip to content
Advertisement

make using autotools gives undefined reference errors while custom Makefile works fine

I’m trying to convert the build mechanism of ccextractor (Open source closed caption extractor) from custom Makefile to Autotools generated Makefile.

Current Makefile looks like this:

JavaScript

Building through above Makefile works fine. My Makefile.am looks like this:

JavaScript

If I run make after autoreconf -i on above file, build fails with error:

JavaScript

If I run ./configure as ./configure LIBS="-lm -lz" build fails with errors as:

JavaScript

tree in src dir is:

JavaScript

And also, all includes are done with full path in sub directories of src, like for a file in gpacmp4 directory, #include <gpac/avparse.h>. All but the main ccextractor.c file, for which all the -I flags are provided.

To refer ccextractor original code: https://github.com/CCExtractor/ccextractor

The original Makefile will be in linux directory.

PS: Currently I’m trying to get the ccextractor build all the checks will be introduced later. For simplified mechanism ccextractor/linux/build is useful to refer.

Even the slightest help is appreciated.

UPDATE: (courtesy of @MadScientist) I updated Makefile.am as:

JavaScript

The build script which builds “ccextractor” perfectly fine is:

JavaScript

Here are some initial statements which make invokes:

JavaScript

Statement which make invokes just before showing undefined reference errors:

JavaScript

PS: Sorry for the delay in update. Any help is appreciated.I tried many things including changing the path of the #include <path/to/header> statements in code and then adding -I statement in CFLAGS but that didn’t help either. Almost all the undefined reference errors are from the functions declared in the headers residing in subdirectories of directories in source like, src/dir/subdir the -I flags are added only till src/dir/ and then the files in src/dir/ have statements like #include<subdir/filename.h>.

PPS: I used grep -r "<Name_of_function_leading_to_error>" . in src to find out the declaration header.

Advertisement

Answer

You don’t show the line make invoked to link your code, which would be very useful.

However, you don’t want to put libraries into the LDLFLAGS (or AM_LDLFAGS) variable; that variable is for linker flags like -L, etc. You should use LDADD:

JavaScript

If you look at the link line that make is generating you’ll see all these options coming BEFORE any of your object files on the link line; that’s not right. The GNU binutils ld is a single-pass linker, which means that the order of -l flags is very important for proper linking.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement