I'm getting a linker error when building log4cplus (versions and platforms below).
libtool: link: x86_64-w64-mingw32-g++ -g -O2 -Wall -fdiagnostics-show-caret -Wextra -pedantic -Wstrict-aliasing -Wstrict-overflow -Woverloaded-virtual -Wc++0x-compat -Wc++11-compat -Wundef -Wshadow -Wformat -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wno-variadic-macros -fvisibility=hidden -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -o .libs/loggingserver.exe loggingserver.o ../src/.libs/liblog4cplus.dll.a -lws2_32 -ladvapi32 -lkernel32 -L/usr/local/lib
loggingserver.o: In function `SharedObject':
/cygdrive/c/Users/user/dev/log4cplus-1.1.2/loggingserver/../include/log4cplus/helpers/pointer.h:64: undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
collect2: error: ld returned 1 exit status
Makefile:301: recipe for target 'loggingserver.exe' failed
make[1]: *** [loggingserver.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/user/dev/log4cplus-1.1.2/loggingserver'
Makefile:428: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
Log4cplus versions tested: 1.1.0 and 1.1.2
Compilers tested: mingw64 (from here: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/)
Tested on Windows 7 and on Win7 under Cygwin. Also tested with with 64 and 32-bit target platforms. And tested with both Win32 threads and POSIX threads version of mingw64.
I've also tried playing around with some defines to try and force POSIX use in place of Windows, with no joy. For example, I tried adding "-D LOG4CPLUS_USE_PTHREADS" which then caused the compiler to not find pthread.h. I then tried adding "-I /usr/x86_64-w64-mingw32/sys-root/mingw/include" which causes many, different, errors.
A workaround would be very welcome if a fix is not practical.
So you are cross compiling from Cygwin to Windows using MinGW64. What is your configure script command line? I will try to reproduce it.
I've tried both cross-compiling, and compiling directly under MinGW64 (via MSYS), both with a simple ./configure and with adding a --prefix= (which is, of course, unlikely to affect this issue). If you need any more details just ask.
I can reproduce it. I am looking into it.
I think we have encountered a MinGW/GCC bug. The constructor symbol never does get exported out of the DLL. What is the exact output of
g++ -v
for you? Can you update GCC to a newer one?My GCC is
gcc version 4.8.1 (GCC)
.And the MSYS environment is
MINGW32_NT-6.1 XXX 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys
In the mean time, please use the attached patch to work around the issue.
Thanks for the patch, I'll try and it let you know if there are any further issues :)
To answer your questions:
MINGW32_NT-6.1 XXX 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
gcc version 4.8.2 (rev0, Built by MinGW-W64 project)
I am closing is as fixed.