1

I'm having trouble getting a third party library (libconfig++) to work in Qt.

When compiling in Qt, I get error messages such as:

undefined reference to `_imp___ZN9libconfig6ConfigC1Ev'
undefined reference to `_imp___ZN9libconfig6Config8readFileEPKc'
undefined reference to `_imp___ZNK9libconfig6Config5writeEP6_iobuf'

etc.

In my .pro file, I have:

LIBS += -L$$PWD/libconfig/lib -lconfig++

And I've added libconfig++.dll and libconfig++.lib to the correct folder.

This project uses another 3rd party library (in a similar way) successfully so I don't think it's a syntax or include problem.

It seems like it might be a C++ name mangling issue? How can I confirm this?

Right now, I build the library in VS 2008 (I've tried building it both as a dynamic and static library, neither work). I think I've been able to do this in the past with other libraries. Is there some flag in VS that I'm not setting correctly?

Thanks

timrau
  • 22,578
  • 4
  • 51
  • 64
Peter991
  • 125
  • 1
  • 1
  • 5
  • 1
    Have you confirmed that the library and its path appear correctly in the build output? – Troubadour Aug 22 '11 at 19:49
  • Yes, the path appears correctly. I have everything identical to how I've included the other 3rd party library and the code works fine if I removed references to libconfig in my code. I strongly suspect name-mangling, but I don't know how to confirm that this is the problem (or how to fix it) – Peter991 Aug 22 '11 at 20:04
  • Configuration Properties->C/C++->Advanced->Compile As set to Compile As C++ Code (/TP)? libconfig set as a dependency (Project->Project Dependencies...)? – Gnawme Aug 22 '11 at 20:22
  • How are you compiling the application that uses that library ? The name mangling scheme indicates you are compiling with MinGW/gcc Qt libraries, and you can't mix a C++ library compiled with VC++ with it (a C library would be ok). – alexisdm Aug 22 '11 at 22:01
  • Are you sure the .dll name shouldn't be `config++.dll`? Note the different library naming conventions between Unix-like and Windows. On Unix-like the library .so files start with `lib` prefix, which is not included in the `-l` linker option. On Windows, .dll files do not have implicit `lib` prefix. In other words, Unixy `libconfig++.so` file would typically be `config++.dll` on Windows. – hyde Aug 27 '15 at 07:27

1 Answers1

2

If your library is called "libconfig++.lib" you might have to change

LIBS += -L$$PWD/libconfig/lib -lconfig++ 

to

LIBS += -L$$PWD/libconfig/lib -llibconfig++ 
Tim Meyer
  • 12,210
  • 8
  • 64
  • 97