Reputation: 4656
Is it possibleto set such flags in Makefile.am instead? That will solve the problem I asked at https://stackoverflow.com/questions/22617744/how-to-disable-the-runtime-checking-of-dynamic-libraries-if-they-are-not-used.
Upvotes: 0
Views: 1942
Reputation: 15788
If you are using Autoconf and Automake, then you should be able to pass in linker flags at compile time to make using the following:
make LDFLAGS='-L/my/nonstandard/prefix/lib' target
Additionally, you can do this for CC, CFLAGS, CPP, CPPFLAGS, and LIBS. For example:
make CC=gcc-4.2 \
LIBS='-lmylibrary -lhislib ../lib/libcustom.a' \
LDFLAGS='-L/opt/vend/lib' \
CPPFLAGS='-I../include' \
CFLAGS='-Wall' \
target
If you want to make them permanent in the make file, add them the to automake variables:
AM_LIBS = -lmylibrary -lhislib ../lib/libcustom.a
AM_LDFLAGS = -L/opt/vend/lib
AM_CPPFLAGS = -I../include
AM_CFLAGS = -Wall
Using the above variables, will still allow you to add flags by passing them to make using the previous method.
Upvotes: 1
Reputation: 22318
Some linkers have options to ignore unresolved symbols at link time - as long as you're certain the library will be available at load time. e.g., For GNU ld, there's: --unresolved-symbols
, where an option like: --unresolved-symbols=ignore-in-shared-libs
might be appropriate. The OS X (Mach-O) linker has: -undefined <error|warning|suppress|dynamic_lookup>
When running a program, all symbols must be resolved by the dynamic linker / loader.
This shouldn't be confused with dynamic loading facilities, which require you to load libraries at runtime, and fetch a function pointer or handle for a given function name.
For the program 'prog'
, you can add extra flags to prog_LDFLAGS
in Makefile.am
.
Upvotes: 2