link flag order error



  • Hello:

    I am using qmake 4.7.4.

    I am trying to figure out how to set up my prog.pro file so that it will fix a link error.

    Here are some of my current prog.pro flags:

    TEMPLATE = app
    TARGET = prog
    MAKEFILE = make_prog
    QMAKE_CFLAGS += -ansi -std=c99 -DTOOL_FAMILY=gnu -DTOOL=gnu $$INCLUDEPATH
    HOME_DIR = $$(PWD)
    SRC_DIR = $$HOME_DIR/
    CONFIG = build_all x11 staticlib
    DESTDIR = linux
    OBJECTS_DIR = $$DESTDIR/obj
    DEFINES += LINUX_BUILD
    QMAKE_LFLAGS = -Wl

    (include and lib stuff excluded for brevity)

    SOURCES = $$SRC_DIR/prog.c

    And here is the current qmake output in a makefile:

    $(TARGET): $(OBJECTS)
    @$(CHK_DIR_EXISTS) linux/ || $(MKDIR) linux/
    $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

    ... only this fails at link time.

    I can get prog to link by moving the "$(LFLAGS)" statement to the end of the line so that it looks like this:

    $(TARGET): $(OBJECTS)
    @$(CHK_DIR_EXISTS) linux/ || $(MKDIR) linux/
    $(LINK) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) $(LFLAGS)

    I am not saying one way is right over the other, but assuming what I want is not totally insane, what do I have to include in my prog.pro file to make the flag ordering fit my needs?

    Maybe I am missing something obvious as I read through the various qmake man pages. Thoughts?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The thing is: you don't pass any flags. Wl should be followed by a linker flag.



  • I removed -Wl from QMAKE_LFLAGS (it was not supposed to be there anyways). no difference.


  • Lifetime Qt Champion

    Re-reading your .pro file content, I just saw that you replace the content of CONFIG which is a bad idea.

    If you don't want your project to be linked with Qt just add CONFIG -= qt


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.