G++, SDL Compilation problem (compiler does not see the library) - c++

after updating g++ to 11.2.0 (before that I had a very old version), I can't compile my project with the same command. For some reason, the compiler cannot find the sdl library, although everything worked fine before.
C:\Users\*****\Desktop\****>g++ -I/src/include -L/src/lib -o main main.cpp -lmingw32 -lSDL2_ttf -lSDL2main -lSDL2 -lSDL2_image
main.cpp:5:10: fatal error: SDL2/SDL.h: No such file or directory
5 | #include <SDL2/SDL.h>
| ^~~~~~~~~~~~
compilation terminated.
I also tried to use the local path, but still unsuccessful. Then it gives me this error.
C:\Users\*****\Desktop\*****>g++ -Isrc/include -Lsrc/lib -o main main.cpp -lmingw32 -lSDL2_ttf -lSDL2main -lSDL2 -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.dll.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_ttf.a when searching for -lSDL2_ttf
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2main.a when searching for -lSDL2main
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2main.a when searching for -lSDL2main
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2.a when searching for -lSDL2
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib\libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.dll.a when searching for -lSDL2_image
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src/lib/libSDL2_image.a when searching for -lSDL2_image
collect2.exe: error: ld returned 1 exit status

Related

Error while compiling, (using a 3rd party header file.) (olcPixelGameEngine) in Ubuntu 20.04

I am using a header file named OlcPixelGameEngine, and one more header file, but when I run the compile command, I get a big error.
This is the command to compile the cpp program.
g++ main.cpp -o main -luser32 -lgdi32 -lopengl32 -lgdiplus -lShlwapi -lstdc++fs -static -std=c++17 -lxinput9_1_0 -lole32 -loleaut32 -ldinput8 -ldxguid -ldwmapi
and this is the error:-
/usr/bin/ld: cannot find -luser32
/usr/bin/ld: cannot find -lgdi32
/usr/bin/ld: cannot find -lopengl32
/usr/bin/ld: cannot find -lgdiplus
/usr/bin/ld: cannot find -lShlwapi
/usr/bin/ld: cannot find -lxinput9_1_0
/usr/bin/ld: cannot find -lole32
/usr/bin/ld: cannot find -loleaut32
/usr/bin/ld: cannot find -ldinput8
/usr/bin/ld: cannot find -ldxguid
/usr/bin/ld: cannot find -ldwmapi
collect2: error: ld returned 1 exit status
I am using Linux, Ubuntu 20.04.

issue with mingw-w64 and SDL2 linking

I am trying to follow an SDL tutorial and compile a c++ file that uses SDL. I am on windows 10, and was originally using MinGW.
Past a certain point I realized my MinGW installation was having issues unrelated to SDL, so I switched to MinGW-w64 instead, which cleared up the non-SDL issue, but now when I try to compile anything with SDL it can't find lSDL2 or lSDL2main. It does, however, skip over various files saying that they are incompatible.
I suspect it might be a 32 bit/64 bit incompatibility, but I'm not sure how this is happening, as even when I explicitly make sure to use the 32 bit g++ compiler, the issue persists. For reference, the command I put into the command prompt is
x86_64-w64-mingw32-g++ 04_key_presses.cpp
-IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w
-Wl,subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o key_presses
and the error messages are
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2main.a when searching for -lSDL2main
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib\libSDL2main.a when searching for -lSDL2main
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2main.a when searching for -lSDL2main
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2.dll.a when searching for -lSDL2
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2.a when searching for -lSDL2
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib\libSDL2.a when searching for -lSDL2
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2.dll.a when searching for -lSDL2
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\mingw_dev_lib\lib/libSDL2.a when searching for -lSDL2
C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2
collect2.exe: error: ld returned 1 exit status
Your compiler is x86_64-w64-mingw32-g++. That's the 64-bit compiler.
The 32-bit compiler is i686-w64-mingw32-g++.exe. The 64-bit linkage
that you are attempting with:
x86_64-w64-mingw32-g++ 04_key_presses.cpp \
-IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w \
-Wl,subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o key_presses
skips your incompatible 32-bit SDL2 libraries.
The 64-bit compiler can build either 64- or 32-bit targets, building
64-bit by default. To target 32-bit, pass -m32 for both compilation
and linkage. As you doing both with one command you need only pass it once:
x86_64-w64-mingw32-g++ 04_key_presses.cpp -m32 \
-IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w \
-Wl,subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o key_presses

How to compile 32-bit application via Clion 2017.1 under Windows 10 x64?

I use Windows 10 x64 and Clion 2017.1 to create my C++ applications, and under x64 system it works fine.
But today I run my app under Windows 7 x32, and got this error: "Version of this file is not compatible with Windows version. Get required version of application (32-bit or 64-bit) via system information":
I tried to compile it with "-m32" flags directly from Windows Console (cmd.exe), like this:
g++.exe -m32 path\to\source\file\file.cpp -o exe_file_name
Also I tried to modify my CMakeLists.txt file by adding this line:
set_target_properties(ProjectName PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
Both ways returns this errors:
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libkernel32.a when searching for -lkernel32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lkernel32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libuser32.a when searching for -luser32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -luser32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libgdi32.a when searching for -lgdi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgdi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libwinspool.a when searching for -lwinspool
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwinspool
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libshell32.a when searching for -lshell32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libole32.a when searching for -lole32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lole32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\liboleaut32.a when searching for -loleaut32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -loleaut32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libuuid.a when searching for -luuid
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -luuid
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libcomdlg32.a when searching for -lcomdlg32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcomdlg32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libadvapi32.a when searching for -ladvapi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0\libstdc++.a when searching for -lstdc++
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lstdc++
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmingw32.a when searching for -lmingw32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0\libgcc.a when searching for -lgcc
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0\libgcc_eh.a when searching for -lgcc_eh
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmoldname.a when searching for -lmoldname
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmingwex.a when searching for -lmingwex
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwex
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmsvcrt.a when searching for -lmsvcrt
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libpthread.a when searching for -lpthread
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpthread
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libadvapi32.a when searching for -ladvapi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libshell32.a when searching for -lshell32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libuser32.a when searching for -luser32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -luser32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libkernel32.a when searching for -lkernel32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lkernel32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libiconv.a when searching for -liconv
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmingw32.a when searching for -lmingw32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0\libgcc.a when searching for -lgcc
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0\libgcc_eh.a when searching for -lgcc_eh
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmoldname.a when searching for -lmoldname
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmingwex.a when searching for -lmingwex
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwex
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib\libmsvcrt.a when searching for -lmsvcrt
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
How I can deal with it?
P.S. I saw this links:
Compiling for 32-bit Windows C
Compile console app as 32-bit
But I still don't understand how to solve my problem.
Thanks for any help.
It's not enough to pass in -m32, you also need to have the 32-bit libraries. The easiest thing to do is install the 32-bit version of mingw32 (it seems you currently have the 64-bit version installed), then change CLion to use the new installation:
File > Settings... > Build, Execution, Deployment > Toolchains
Set MinGW home to the new 32-bit install location.
1) Install some new stuff (32bit compiler)
sudo apt-get install gcc-multilib
2) On CLion open the file "CMakeLists.txt" and include these two lines:
set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_FLAGS -m32)
3) Build (Debug or Release)
4) Check for 32-bit version on Terminal
file executable_file_name
It must show something like this:
executable_file_name: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=28138301f6ffe9cee
That's it.
After a lot of searching in the web (and because I have no answers on my question on CLion IDEs Support) I remove CLion from my laptop and move my C++ development to Eclipse IDE for C/C++ Developers.
I think that it is very flexible and comfortable IDE, and to compile my solution under Eclipse I just need to go to Solution_name (Right mouse click) -> Properties -> C/C++ Build -> Settings -> (In the MinGW C++ Linker) Miscellaneous -> (On the right pane, in "Linker Flags" field) and simply add "-m32" flag.
Sometimes free IDE like Eclipse has more features and is more comfortable then chargeable IDEs like CLion.
P.S. JetBrains team made me very upset.

During compilation of 32 bit binaries in to 64 bit fedora 17 in c++ getting error :

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../lib/libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../lib/libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /lib/../lib/libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /lib/../lib/libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /lib/libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /lib/libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/libgtest.so when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/libgtest.a when searching for -lgtest
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../lib/libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /lib/../lib/libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /lib/../lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /lib/libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/libgtest_main.so when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: cannot find -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.7.2/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
I have tried so many options:
tried installng Gcc multilib "yum install glibc-devel.i686 glibc.i686"
It is not working
Also tried installing sudo chmod -R 777 libusb-compat-0.1.5
not working
Please answer if anyone having the solution for this.
I want to compile our Gtest 32 bit object files of builtroot on 64 bit platform on fedora 17.

Cross compiling a Webots controller

I'm trying to use MinGW to cross compile from Linux to Windows a robotic controller (.exe) for Webots (simulation software).
Webots supplies a Makefile.include file common to all platforms, that prepares the building environment for compilation (necessary dependencies):
My current makefile, where I set several variables according to MinGW and my webots installation:
WEBOTS_HOME = /usr/share/webots/resources/windows_home
#WEBOTS_HOME = /usr/share/webots
RESOURCES_PATH = $(WEBOTS_HOME)/resources/projects/robots/darwin-op
SOURCES_PATH = src
SOCKET_PATH = ../../../extra/socket/src
KIN_INCLUDE = ../../lib/OPKinematics/include
KIN_LIB = ../../lib/OPKinematics/lib/libOPKinematics64.a
EXT_INCLUDE = ../../lib/include
CFLAGS = -g -Wall
INCLUDE=-I$(RESOURCES_PATH)/libraries/darwin/darwin/Framework/include -I$(RESOURCES_PATH)/include -I$(KIN_INCLUDE) -I$(EXT_INCLUDE) -I$(SOCKET_PATH)
LIBRARIES = -Wl,-Bstatic -lws2_32 -lpthread -lboost_system-mt -lboost_serialization-mt -static-libgcc -static-libstdc++ -Wl,-Bdynamic $(RESOURCES_PATH)/libraries/darwin/darwin.dll $(KIN_LIB)
CXX_SOURCES = $(SOURCES_PATH)/main.cpp $(SOURCES_PATH)/DarwinRobot.cpp $(SOURCES_PATH)/dyn_system.cpp $(SOURCES_PATH)/writefilestuff.cpp $(SOCKET_PATH)/socket_boost.cpp
#CC=x86_64-w64-mingw32-g++
CXX=x86_64-w64-mingw32-g++
EXE_EXTENSION=.exe
OSTYPE=windows
CFLAGS += -DWIN_MAKE
# ----------------------------------------------------
#
### Do not modify: this includes Webots global Makefile.include
space :=
space +=
WEBOTS_HOME_PATH=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
include $(WEBOTS_HOME_PATH)/resources/Makefile.include
# No pre or post build rules are necessary, override the default set on Makefile.include
pre-build: ;
post-build: main-build ;
#echo $(CC)
#echo $(OSTYPE)
# ---------------------------------------------------
Additionaly, I've installed Webots on my Windows box and copied the installation folder to the installation folder on my Linux box, so that I could have access to the pre-compiled Windows libraries.
The problem is when the linker tries to find a couple of libraries (-lController and -lCppController, which are appended inside Makefile.include):
# linking build/release/darwin_socket.exe
x86_64-w64-mingw32-g++ -s -Wl,--enable-auto-import -o build/release/darwin_socket.exe build/release/main.o build/release/DarwinRobot.o build/release/dyn_system.o build/release/writefilestuff.o build/release/socket_boost.o -Wl,-Bstatic -lws2_32 -lpthread -lboost_system-mt -lboost_serialization-mt -static-libgcc -static-libstdc++ -Wl,-Bdynamic /usr/share/webots/resources/windows_home/resources/projects/robots/darwin-op/libraries/darwin/darwin.dll ../../lib/OPKinematics/lib/libOPKinematics64.a -lmingw32 -B"/usr/share/webots/resources/windows_home\mingw\lib\gcc\mingw32\5.1.0" -L"/usr/share/webots/resources/windows_home/lib" -lController -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libController.a when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/Controller.lib when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/Controller.dll when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libController.a when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libController.a when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/Controller.lib when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/Controller.dll when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/Controller.lib when searching for -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32 /bin/ld: cannot find -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libCppController.a when searching for -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/CppController.dll when searching for -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libCppController.a when searching for -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/libCppController.a when searching for -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: skipping incompatible /usr/share/webots/resources/windows_home/lib/CppController.dll when searching for -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lCppController
collect2: error: ld returned 1 exit status
/usr/share/webots/resources/windows_home/resources/Makefile.include:529: recipe for target 'build/release/darwin_socket.exe' failed
make: *** [build/release/darwin_socket.exe] Error 1
From what I've gathered, this issue is usually caused when trying to link 32-bit libraries to a 64-bit binary (or vice-versa), but I have no -m32 or -m64 flags on my makefile or on Makefile.include. My OSs are both 64-bit, so I assume there should not be any problem with the type of libraries.
I've tried using Webots' native linux installation folder instead, but I encounter similar issues:
# linking build/release/darwin_socket.exe
x86_64-w64-mingw32-g++ -s -Wl,--enable-auto-import -o build/release/darwin_socket.exe build/release/main.o build/release/DarwinRobot.o build/release/dyn_system.o build/release/writefilestuff.o build/release/socket_boost.o -Wl,-Bstatic -lws2_32 -lpthread -lboost_system-mt -lboost_serialization-mt -static-libgcc -static-libstdc++ -Wl,-Bdynamic /usr/share/webots/resources/projects/robots/darwin-op/libraries/darwin/darwin.dll ../../lib/OPKinematics/lib/libOPKinematics64.a -lmingw32 -B"/usr/share/webots\mingw\lib\gcc\mingw32\5.1.0" -L"/usr/share/webots/lib" -lController -lCppController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lController
/usr/lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lCppController
collect2: error: ld returned 1 exit status
/usr/share/webots/resources/Makefile.include:529: recipe for target 'build/release/darwin_socket.exe' failed
make: *** [build/release/darwin_socket.exe] Error 1
which is rather strange, because both libController.so and libCppController.so are present inside /usr/share/webots/lib/.
So what exactly am I missing here?