-1

I have 3 libraries that I have to use, of course I've got the header file associated for each one. To include these libraries I write this in my .pro file :

LIBS += -L $$quote(C:/libs/ARINC825/lib/VC/amd64/) -larinc825
LIBS += -L $$quote(C:/libs/SDK/lib/VC/amd64/) -lntcan
LIBS += -L $$quote(C:/libs/SDK/lib/VC/amd64/) -lirigb

These libraries are for the use of a CAN card.

When I compile, the compilator can't find the functions associated to the first library : -larinc825

Here's an error line for example : undefined reference to arincHandleOpen

Can you explain me why my include fail ?

Thanks.

PS : I did some research, and try to use this topic Adding external library into Qt Creator project but it gives no result.

EDIT : I'm on QT5, I can use the minWG compiler or the VisualStudio 2010 compiler.

EDIT2 : Don't know why, but this seems to works :

LOCATION1="C:\Program Files\ESD\CAN\ARINC825\lib\VC\i386"
INCLUDEPATH += "$$LOCATION1/include"
QMAKE_LIBDIR += "$$LOCATION1"
LIBS += -larinc825

LOCATION2="C:\Program Files\ESD\CAN\SDK\lib\VC\i386"
INCLUDEPATH += "$$LOCATION2/include"
QMAKE_LIBDIR += "$$LOCATION2"
LIBS += -lirigb -lntcan
Community
  • 1
  • 1
Evans Belloeil
  • 2,413
  • 7
  • 43
  • 76

1 Answers1

0

Since you are linking a .lib library specific to Windows platform here is what I have in my .pro file:

win32 {
    equals(BITNESS, 32)
    {
        LIBS += "C:\Program Files (x86)\AMD APP SDK\2.9\lib\x86\OpenCL.lib"
    }
    equals(BITNESS, 64)
    {
        LIBS += "C:\Program Files (x86)\AMD APP SDK\2.9\lib\x86_64\libOpenCL.a"
    }
}

MinGW has some problem with linking 64 bit libraries in .lib format. So I suggest you to try to link the .a file. After reading rubenvb's comment, it is clear that MinGW has a generic issue of not being able to link 64 bit libraries in .lib format. So if you want to link in 64 bit you MUST have a .a version of your library.

The BITNESS is a variable that is passed to qmake which is used to check if the build is for 32 bit or 64 bit. You need to set these only once for your project. Your project must be using 2 kits: 1 for the 32 bit compiler and other for the 64 bit compiler. You can set the BITNESS variable as follows:

DEFINES+="BITNESS=64"

This line should be added in the Build steps for qmake. Similarly add DEFINES+="BITNESS=32" for 32 bit kit.

Cool_Coder
  • 4,888
  • 16
  • 57
  • 99
  • have you added the BITNESS variable in your kit? – Cool_Coder Jul 16 '14 at 14:22
  • Yes, but I don't have .a file, only .lib, and my system is on 64 bits. – Evans Belloeil Jul 16 '14 at 14:25
  • so try with the .lib file instead and see if it works. – Cool_Coder Jul 16 '14 at 14:28
  • No, still can't find the functions – Evans Belloeil Jul 16 '14 at 14:33
  • 64-bit static/import libraries can indeed not be linked by GNU ld (which is what MinGW uses). This is a general incompatibility and not related to OpenCL in any way. AMD's OpenCL SDK delivers a GNU ld `libopencl.a` for both architectures, so there should be no problem if you used [`-L` and `-l`](http://qt-project.org/doc/qt-5/qmake-variable-reference.html#libs) instead of dropping the full file path in the `LIBS` variable. – rubenvb Jul 16 '14 at 14:39
  • @Cool_Coder: Also, I suggest you use [this](http://qt-project.org/forums/viewthread/18874/#92037) for your OpenCL linking... Until qmake gets a decent way to detect target architecture, you are indeed stuck with an extra define. You could of course just use `CONFIG += x86` when invoking qmake and just use the string `x86` as a test. – rubenvb Jul 16 '14 at 14:49
  • It is indeed the most elegant solution. But where are AMDAPPSDKinclude and AMDAPPSDKlib defined? My system environment only has AMDAPPSDK defined. – Cool_Coder Jul 16 '14 at 15:03