Author Topic: libconfig library linker error  (Read 11421 times)

Blue Pill

  • Guest
libconfig library linker error
« on: October 22, 2007, 11:09:11 pm »
I'm trying to use libconfig library (http://www.hyperrealm.com/main.php?s=libconfig) in my project with recent version of CodeBlocks and MinGW compiler. It's a compact parser for application configuration files. The author states:
"The library includes bindings for both the C and C++ languages. It works on POSIX-compliant UNIX systems (GNU/Linux, Mac OS X, Solaris, FreeBSD) and Windows (2000, XP and later)."
So I import Visual Studio solution which contains C and C++ version of library and example program for each version. I can build both libraries without any problem, and the C example program builds and behaves nicely. But while linking the C++ sample program yields following error:

Code
-------------- Build: Debug Win32 in libconfig++_stub ---------------
Linking console executable: libconfig++_stub.exe
libconfig++_stub.Debug Win32\samples\c++\stubcpp.o:stubcpp.cpp:(.text+0x173): undefined reference to `_imp___ZN9libconfig6ConfigC1Ev'
libconfig++_stub.Debug Win32\samples\c++\stubcpp.o:stubcpp.cpp:(.text+0x1d0): undefined reference to `_imp___ZN9libconfig6Config4readEP6_iobuf'
libconfig++_stub.Debug Win32\samples\c++\stubcpp.o:stubcpp.cpp:(.text+0x1fa): undefined reference to `_imp___ZNK9libconfig6Config6lookupEPKc'
libconfig++_stub.Debug Win32\samples\c++\stubcpp.o:stubcpp.cpp:(.text+0x204): undefined reference to `_imp___ZNK9libconfig7SettingcvlEv'

----(bunch of errors omitted)------

collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
48 errors, 0 warnings

I have added "libconfig++.a" to linker libraries. What's missing?

Blue Pill

  • Guest
Re: libconfig library linker error
« Reply #1 on: October 24, 2007, 12:35:45 am »
Let me also include the command line parameters form build log:
Code
mingw32-g++.exe -DWIN32 -D_CONSOLE  -w -DWIN32 -D_DEBUG -D_CONSOLE    -I..\libConfig -IC:\MinGW\include  -c "C:\Documents and Settings\Administrator\My Documents\Josip\CodeBlocks\libConfig\samples\c++\stubcpp.cpp" -o "libconfig++_stub.Debug Win32\samples\c++\stubcpp.o"
mingw32-g++.exe -L..\libConfig -LC:\MinGW\lib  -o libconfig++_stub.exe "libconfig++_stub.Debug Win32\samples\c++\stubcpp.o"    -lconfig++

I don't know much about dynamic libraries, so any insight would be useful.

Blue Pill

  • Guest
Re: libconfig library linker error
« Reply #2 on: October 25, 2007, 10:02:49 am »
I found the problem with help of library author. The source files of C++ version of library used extensions .c++ and .h++ which are not standard. Codeblocks added those files to build target list, but options Build and Link were disabled for those files. So, when building C++ version of library, only files for C were built and no errors were reported. Kind of hard to figure out if you don't know were to look.