2

I am trying to build a plain c++ qmake project in Qt, I have linked the library required by my code using the built in "add library..." wizard. I have set the library as static.

This then modifies my .pro file with this additional text:

win32: LIBS += -L$$PWD/./ -lfusionTrack32

INCLUDEPATH += $$PWD/.
DEPENDPATH += $$PWD/.

win32:!win32-g++: PRE_TARGETDEPS += $$PWD/./fusionTrack32.lib
else:win32-g++: PRE_TARGETDEPS += $$PWD/./libfusionTrack32.a

I then try to build the project and this error is returned:

mingw32-make[1]: *** No rule to make target'//icnas1.cc.ic.ac.uk/hd1714/ftk_basic/./libfusionTrack32.a', needed by 'release\ftk_basic.exe'.  Stop.
Makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2

I have am trying to add the 32bit library but I get the same error when trying to link the 64 library as well. The library is a .lib import library. I currently have all the files on the same folder. I using windows 7, minGW 32, g++.

also if I delete the line for the .a file ( that I don't not want ):

 else:win32-g++: PRE_TARGETDEPS += $$PWD/./libfusionTrack32.a

then instead I get the two errors:

 cannot find -lfusionTrack32
 error: ld returned 1 exit status

Any help is much appreciated.

Harry de winton
  • 969
  • 15
  • 23
  • The library is not named libfusionTrack32.a ? – perencia Jul 20 '16 at 11:26
  • unfortunately not @perencia , the library is called fusionTrack32.lib, I believe the .a files are for unix and .lab are the equivalent for windows...[see here](http://stackoverflow.com/questions/2337949/whats-the-difference-between-lib-and-a-files) – Harry de winton Jul 20 '16 at 12:18
  • hence my confusion at why it would included this in the .pro file after I unchecked the boxes for mac and linux in the wizard. – Harry de winton Jul 20 '16 at 12:19

1 Answers1

1

My suggestion is that you can directly modify the .pro file by yourself not the wizard. So, please first undo all changes applied to the .pro file and then simply add the library using the following commands:

# Absolute address of the .lib file
LIBS += c:/mylib/mylib.lib

# Absolute address of its header files (if any)
INCLUDEPATH += c:/mylib/include

That's it! more info

frogatto
  • 28,539
  • 11
  • 83
  • 129
  • Frogatto I have done as you said, I know get several error messages, mainly for `undefined reference` and also some lovely `in function` errors. However these functions are not in the library so I think you fixed it, Congratulations!! you did it :) Thank you very much – Harry de winton Jul 21 '16 at 09:13