Menu

#282 Linker error under MinGW64

v1.1.3
closed
5
2013-11-28
2013-11-18
No

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.

Discussion

  • Václav Haisman

    Václav Haisman - 2013-11-18

    So you are cross compiling from Cygwin to Windows using MinGW64. What is your configure script command line? I will try to reproduce it.

     
  • Václav Haisman

    Václav Haisman - 2013-11-18
    • assigned_to: Václav Zeman
     
  • martian_manhunter

    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.

     
  • Václav Haisman

    Václav Haisman - 2013-11-19

    I can reproduce it. I am looking into it.

     
  • Václav Haisman

    Václav Haisman - 2013-11-19
    • labels: --> v1.1.2, build
     
  • Václav Haisman

    Václav Haisman - 2013-11-19

    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).

     
  • Václav Haisman

    Václav Haisman - 2013-11-19

    And the MSYS environment is MINGW32_NT-6.1 XXX 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys

     
  • Václav Haisman

    Václav Haisman - 2013-11-19
    • labels: v1.1.2, build --> v1.1.2, build, gcc
     
  • Václav Haisman

    Václav Haisman - 2013-11-19
    • labels: v1.1.2, build, gcc --> v1.1.2, build, gcc, mingw64, mingw
     
  • Václav Haisman

    Václav Haisman - 2013-11-19

    In the mean time, please use the attached patch to work around the issue.

     
  • martian_manhunter

    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)

     
  • Václav Haisman

    Václav Haisman - 2013-11-28
    • labels: v1.1.2, build, gcc, mingw64, mingw --> v1.1.2, build, gcc, mingw64, mingw, fixed
    • status: open --> closed
     
  • Václav Haisman

    Václav Haisman - 2013-11-28

    I am closing is as fixed.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.