Append arguments to end of compile line - gcc fails where clang links

Hi all,

TLDR; Is there a way to have make append arguments at the end of the final build command or at least after the object files?

I am trying to statically link against a library using the build process (pardon my terminological mistakes). In my Makefile, I am doing this:
Code:
LDFLAGS+=       ${.OBJDIR}/../lib/libogit.a
...
.include <bsd.prog.mk>

libogit.a is the static library I am linking against. This works fine in Clang but I run into problems with GNU gcc because for gcc the order of arguments matters. Specifically, if the static library is in the beginning of the command, gcc will fail to find symbols exported by the library.

To help make this clear, this line will not work because the library file is referenced before the object files.
gcc ../lib/libogit.a buncha_object_files_go_here.o -o ogit.full

This will work becaus the library is referenced after the object files.
gcc buncha_object_files_go_here.o ../lib/libogit.a -o ogit.full

The reason the library file is referenced at all is because of the LDFLAGS line in my Makefile. Is there an alternative to LDFLAGS that appends arguments to the very end of the build script or at least after the object files?

Why I am using gcc: valgrind displays symbols and source code lines with gcc, but not with clang.
Thanks you!
 
Try using LDADD instead.

For the valgrind, does it want dwarf? If yes, which version? What file says about binaries compiled using gcc and clang?
 
Back
Top