문제

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.

도움이 되었습니까?

해결책 2

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top