0

I imported my Qt application developed on linux to windows. Now when I build my project I am getting this error:

 error: LNK1146: no argument specified with option '/LIBPATH:'

I created a new project on windows and it works perfectly fine. One of the possible reason that would cause this is having spaces in the project path,but there are no spaces in my project path.Could you let me know how I could resolve this issue.

This is my .pro file:

#-------------------------------------------------
#
# Project created by QtCreator 2014-12-08T09:19:31
#
#-------------------------------------------------

QT       += core gui


greaterThan(QT_MAJOR_VERSION, 4): QT += widgets




TARGET = FirstProject
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11

SOURCES += main.cpp\
        firstscreen.cpp \
        secondscreen.cpp \
        thirdscreen.cpp

INCLUDEPATH += C:\Users\user_name\tango\ \
               C:\Users\user_name\omniORB4\ \
               C:\Users\user_name\omnithread.h





HEADERS  += firstscreen.h \
            C:\Users\user_name\tango\ \
            C:\Users\user_name\omniORB4\ \
            C:\Users\user_name\omnithread.h \
            secondscreen.h \
            thirdscreen.h


LIBS += -L -lomnithread \
        -L -lomniORB4 \
        -L -ltango


FORMS    += firstscreen.ui \
            secondscreen.ui \
            thirdscreen.ui
Valla
  • 2,414
  • 11
  • 42
  • 73
  • Did you check LIBPATH in your linux project to see where it was pointing at? Also, do you have a LIBPATH env. variable declared on Windows? Did you check your project options to see if there is a LIBPATH defined and what its path(s) are? – DNT Dec 30 '14 at 18:01
  • @DNT How can I check that in my LIBPATH on linux system. I did not declare any LIBPATH variable on windows? Do I need to do that,because the other project which I created on windows builds fine. – Valla Dec 30 '14 at 18:05
  • Look at this answer here: http://stackoverflow.com/questions/5314735/how-to-add-external-libraries-to-qt4-application-c If your project needs external libraries they should be declared in LIBPATH or (newer) QMAKE_LIBDIR depending on Qt version. Also, if you compare the ported project with the one you created on Windows, what are the differences in the .pro files? – DNT Dec 30 '14 at 18:08
  • @Valla Does any of these answers solve the problem? If so, click on the checkbox near it to select it as the official answer. By doing this, you are helping future visitors of the site. – karlphillip Aug 10 '18 at 12:54
  • @Valla Has this been successfully solved? If so, can you please pick an answer? Or at least ADD an answer to help others? – karlphillip Jul 19 '19 at 09:12
  • @Valla So ... do you feel this has been properly answered? – karlphillip Jan 29 '20 at 14:50

3 Answers3

3

The problem happens because the flag -L was specified, but no library paths were given:

LIBS += -L -lomnithread \
        -L -lomniORB4 \
        -L -ltango

To fix this problem, you must provide the paths where the .lib files are located, which would be something like:

LIBS += -L"C:\\Users\\user_name\\omnithread\\lib"  -lomnithread \
        -L"C:\\Users\\user_name\\omniORB4\\lib" -lomniORB4 \
        -L"C:\\Users\\user_name\\tango\\lib" -ltango

Remember: there must be no empty spaces between -L and the path string.

So doing it like this will also throw the same error:

LIBS += -L "C:\\Users\\user_name\\omnithread\\lib"  -lomnithread \
        -L "C:\\Users\\user_name\\omniORB4\\lib" -lomniORB4 \
        -L "C:\\Users\\user_name\\tango\\lib" -ltango
karlphillip
  • 92,053
  • 36
  • 243
  • 426
1

In your .pro file the problem is probably the empty "-L" when assigning to LIBS. You need to write there the path for the following library specified "-l".

I fixed a less obvious situation like this:

Since the problem was hidden in the response file used by JOM I started JOM manually as executed by qmake. Simply copy the JOM call and execute it with an additional -U parameter to see the content of the response file:

C:\Qt\Tools\QtCreator\bin\jom.exe -U -f Makefile.Debug > x.txt

(of course you have to call it in the directory mentioned in the qmake output)

Next I checked all /LIBPATH: occurrences in x.txt. So it was easy to find the culprit and fix the .pro file.

pi3
  • 1,235
  • 13
  • 15
0

In the current .pro file you specified library names, but didn't specify paths for your external libs. Those '-l' and '-L' keys are used exactly for this.

Some advice:

  • Use relative paths
  • Use some variables in .pro file, like DESTDIR and reference them in lib path argument, like -L"$$DESTDIR"
Adam
  • 93
  • 8
MasterAler
  • 1,614
  • 3
  • 23
  • 35