Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to compile a qt widgets project under Ubuntu 14.04

My .pro file has a line that looks like this:

QMAKE_LFLAGS += -L/usr/local/lib

I could hardly find any documentation on the -L flag but judging by other projects on the internet, the syntax looks fine. However, both Qt Creator 3.5.1 and NetBeans 8.1 fail to compile (or should I say link) the project with the same error:

L/usr/local/lib: Command not found

Notice that the hyphen before the L is now gone. However, I managed to build the project using the terminal with the following set of commands:

make clean
~/Qt/5.5/gcc_64/bin/qmake 

With clean being vital as terminal displays the same error without it. Then I made sure my make is located at /usr/bin/make and I tried to modify my build steps in Qt Creator to look like this (project build directory is filled with black):

This gave me no results either, it still fails to compile on any build/rebuild within IDE with the very same error. Similar errors appear with literally any other flags I try to put there (for instance, -pthread gives me pthread: Command not found).

I have spent hours trying to solve the problem. How could I fix it?

Alright, after spending a few more time I noticed that the head of my .pro file looks like this:

QMAKE_CXX = "g++-4.9"
QMAKE_CC = "g++-4.9"
QMAKE_LINK = $$(CXX)

with CXX being an environment variable that was supposed to be equal to g++-4.9. Turns out it wasn't. After making it look like:

QMAKE_CXX = "g++-4.9"
QMAKE_CC = "g++-4.9"
QMAKE_LINK = "g++-4.9"

the problem got fixed and it compiled successfully. Yaay!

Usually you should not overwrite QMAKE_CXX, QMAKE_CC or QMAKE_LINK by hand, but configure your kits appropriately. To link stuff to your library prefer to add to the qmake variable LIBS instead of QMAKE_LINK. That is the intended and more portable way of using qmake. – Ralph Tandetzky Dec 21, 2015 at 20:00

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.