I know this is a very often asked question and I really browsed through all of the answers already but I could not find my problem and the solution for it as well.
Preface
Using the Cygwin Toolchain within CLion to build a 64bit C++ program worked like a charm. No errors or whatsoever. I then tried to do the same for 32bit and quickly realised it is a lot harder to understand.
CMakeList
Here I added the -m32
flag to the already working CMakeLists.txt
# cmake_minimum_required(VERSION <specify CMake version here>)
project(my_program)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS -m32)
add_library(my_program SHARED library.cpp)
I then used CygWin to download plenty of c++ compilers just to get sure I have at least one of them that might work.
Here is the way I configure it for the 32bit build
After doing so CMake
is rebuilding the build files and then I started compiling the project.
Following Error messages appear (truncated because they actually all are the same but with different "missing" libraries that couldn't be found)
C:\Users\xetra11\.CLion2018.2\system\cygwin_cmake\bin\cmake.exe --build /cygdrive/c/Development/Github/CoopR-HQ-Extension/cmake-build-default --target all -- -j 10
[ 50%] Linking CXX shared library cygCoopR_HQ_Extension.dll
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
C++ compilers used These are the compilers I tried to use. They all yield slighty different error messages but all are unified in the rant for not finding a library
Cygwin compilers:
- C:\cygwin64\bin\x86_64-pc-cygwin-gcc.exe (the one used in this question)
- C:\cygwin64\bin\x86_64-pc-cygwin-gcc-7.3.0.exe
- C:\cygwin64\bin\x86_64-pc-cygwin-g++.exe
- C:\cygwin64\bin\x86_64-pc-cygwin-c++.exe
- C:\cygwin64\bin\i686-pc-cygwin-c++.exe (broken CMake threw errors: link)
- C:\cygwin64\bin\i686-pc-cygwin-cpp.exe (broken CMake threw errors: link)
- C:\cygwin64\bin\i686-pc-cygwin-g++.exe (error occured: link)
- C:\cygwin64\bin\i686-pc-cygwin-gcc-6.4.0.exe (broken CMake threw errors: link)
- C:\cygwin64\bin\i686-pc-cygwin-gcc.exe (broken CMake threw errors: link)
MinGW compilers:
- C:\cygwin64\bin\x86_64-w64-mingw32-c++.exe
- C:\cygwin64\bin\x86_64-w64-mingw32-cpp.exe (broken CMake threw errors: link)
- C:\cygwin64\bin\x86_64-w64-mingw32-g++.exe
- C:\cygwin64\bin\x86_64-w64-mingw32-gcc-6.4.0.exe
- C:\cygwin64\bin\x86_64-w64-mingw32-gcc.exe
- C:\cygwin64\bin\i686-w64-mingw32-c++.exe (no errors)
The last one did not threw any errors but when checking the .DLL with Dependency Walker I found out that all linked .DLLs to this still rely on x64 and therefore Error: Modules with different CPU types were found.
I am a bit tired now and really would appreciate some hints how to get this stuff build the right way. I already think I understood the fact that I have to bring in 32bit libraries. But I don't really know how and why. I assumed that the toolchain have this out of the box.
Please mind that I am fairly unused to C++ on windows.