billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
640 stars 93 forks source link

Linker error for target "ponder" using GCC 6.3.0 (MinGW-w64 MinGW-Builds) #69

Closed FlorianWolters closed 7 years ago

FlorianWolters commented 7 years ago

I try to build Ponder with GCC 6.3.0 (MinGW-w64 MinGW-Builds) using Microsoft Windows 10.0.14393:

cmake -G"CodeBlocks - Ninja" -Hponder-1.3.0 -Bbuild-ponder-1.3.0/x86/mgw63/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=../native/ponder/ponder-1.3.0-x86
cmake --build build-ponder-1.3.0/x86/mgw63/Release --config Release --target install

During compilation of the target ponder the following linker error occurs:

[1/29] Building CXX object CMakeFiles/ponder.dir/src/util.cpp.obj
FAILED: CMakeFiles/ponder.dir/src/util.cpp.obj
D:\win-dev-env\native\mingw-builds\mingw-builds-6.3.0-x86\bin\g++.exe   -DPONDER_EXPORTS -ID:/win-dev-env/build/ponder-1.3.0/include -O3 -DNDEBUG   -std=gnu++11 -MD -MT CMakeFiles/ponder.dir/src/util.cpp.obj -MF CMakeFiles\ponder.dir\src\util.cpp.obj.d -o CMakeFiles/ponder.dir/src/util.cpp.obj -c D:\win-dev-env\build\ponder-1.3.0\src\util.cpp
D:\win-dev-env\build\ponder-1.3.0\src\util.cpp: In function 'int ponder::detail::stricmp(const char*, const char*)':
D:\win-dev-env\build\ponder-1.3.0\src\util.cpp:52:22: error: '_strcmpi' was not declared in this scope
  return _strcmpi(a, b);
                      ^
ninja: build stopped: subcommand failed.

My build environment is not to blame, since I can successful build other C++ libraries using the same environment/toolchain.

billyquith commented 7 years ago

Hi there, thanks for the feedback.

Does __MINGW32__ get defined in a MinGW 64 bit build? Looks like the following include might be causing problems:

https://github.com/billyquith/ponder/blob/master/src/util.cpp#L33

Is there a generic define for the MinGW environment? That is word size agnostic?

FlorianWolters commented 7 years ago

I think MinGW (both x64 and x86) should define __MINGW32__, but I can't tell for sure. I will investigate this later and come back here to report.

billyquith commented 7 years ago

It looks like _MSC_VER can be used: https://gist.github.com/jonforums/968522

billyquith commented 7 years ago

I've changed this. I didn't hear back from you. I'll close the bug. Please get latest and test against that. If there is still a problem re-open the bug.

FlorianWolters commented 7 years ago

The problem seems to be fixed in master, though building with tests does not work:

[51/55] Linking CXX executable test\examples\egtest.exe
FAILED: test/examples/egtest.exe
cmd.exe /C "cd . && D:\win-dev-env\native\mingw-builds\mingw-builds-6.3.0-x86\bin\g++.exe  -O3 -DNDEBUG   test/examples/CMakeFiles/egtest.dir/main.cpp.obj test/examples/CMakeFiles/egtest.dir/simple.cpp.obj  -o test\examples\egtest.exe -Wl,--out-implib,test\examples\libegtest.dll.a -Wl,--major-image-version,0,--minor-image-version,0
  libponder.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
test/examples/CMakeFiles/egtest.dir/simple.cpp.obj:simple.cpp:(.text+0x28f): undefined reference to `ponder::detail::fmt::print(ponder::detail::fmt::BasicCStringRef<char>, ponder::detail::fmt::ArgList)'
test/examples/CMakeFiles/egtest.dir/simple.cpp.obj:simple.cpp:(.text+0xa4b): undefined reference to `ponder::detail::fmt::print(ponder::detail::fmt::BasicCStringRef<char>, ponder::detail::fmt::ArgList)'
test/examples/CMakeFiles/egtest.dir/simple.cpp.obj:simple.cpp:(.text+0xa50): undefined reference to `ponder::uses::reportAll()'
collect2.exe: error: ld returned 1 exit status
[53/55] Building CXX object test/ponder/CMakeFiles/pondertest.dir/function.cpp.obj
ninja: build stopped: subcommand failed.

Building with the option BUILD_TEST=OFF seems to work.