Correcting the GCC command line ordering using Automake

后端 未结 2 939
闹比i
闹比i 2021-02-14 10:22

I have an autotools project that compiles just fine on the Mac, but under Linux (Ubuntu 12.04.1 LTS) the command lines passed to gcc have the libraries out of order

2条回答
  •  臣服心动
    2021-02-14 10:54

    The solution turned out to be the difference between LDFLAGS and LDADD. In short LDFLAGS is added before the object files on the command line and LDADD is added afterwards. Thus, changing Makefile.am to the following solved the problem:

    CFLAGS=-Wall
    bin_PROGRAMS=test
    test_CFLAGS=$(GLIB_CFLAGS)
    test_LDADD=$(GLIB_LIBS)
    test_SOURCES=test.c
    

    It only took tracking down a GCC developer at work to solve. Also, this example I provided is rather poor because test has a defined meaning in some contexts of autotools.

提交回复
热议问题