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
Related
I am trying to learn how to use SDL and I've been trying to get my app to run on other systems. when I try to compile using g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 -static-libgcc -static-libstdc++ -static I get a massive bunch of SDL errors saying undefined and the app doesn't finish compiling. However when running without -static it will compile but not include libc. How would I fix this issue while still being able to run on other systems without them installed?
I am also using MinGW-w64 for GCC
You're missing some flags. Running pkg-config --libs --static sdl2 will tell you the right flags.
If you don't have pkg-config installed (you could get it from MSYS2), you can look up the flags manually in the file called sdl2.pc, which is shipped with SDL2.
For me this command prints -L/mingw64/lib -lSDL2main -lmingw32 -lSDL2main -lSDL2 -mwindows -lmingw32 -ldinput8 -lshell32 -lsetupapi -ladvapi32 -luuid -lversion -loleaut32 -lole32 -limm32 -lwinmm -lgdi32 -luser32 -lm -Wl,--no-undefined -lmingw32 -lSDL2main -lSDL2 -mwindows.
You also need -static, even though it doesn't appear in the output. You can remove -static-libgcc -static-libstdc++, since they're implied by -static.
I installed Cygwin64 on a win7-64 with gcc dev tools and I just noticed that it produces 64bit binaries. (Well, not that surprising :o) Is there a mean to make it producing some 32bit binaries?
I am compiling the socat tool for windows, compiled in 64bit it is working, but I am trying to make another version suitable for an XP-32.
The configure script does not seem to support a -b 32 switch (that I must have seen for ming64 from this thread, and if I try to specify the -m32 switch in CFLAGS for configure it fails:
$ CFLAGS=-m32 ./configure
checking which defines needed for makedepend...
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/dev/tools/nettools/socat/socat-2.0.0-b8':
configure: error: C compiler cannot create executables
See `config.log' for more details
Would the option be to also install Cygwin32, or can I compile 32bit code with another setting or additional cygwin package?
Edit:
I have found that my cygwin64/gcc cannot compile a simple hello.c program in 32bits:
#include <stdio.h>
int main (int argc, char *argv[]){
printf("Hello, world!\n");
return 0;
}
with a gcc -o hello.exe hello.c it works flawlessly, but gcc -o hello.exe hello.c -m32 spits
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../libcygwin.a when searching for -lcygwin
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../libcygwin.a when searching for -lcygwin
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../libcygwin.a when searching for -lcygwin
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lcygwin
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lkernel32
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
configure is part of autotools, and not relevant to the original question. There are two 32 bit runtime environments you can build a C program for. CYGWIN-32 and MINGW32. I will not go into details on the differences, but a cygwin32 program is posix/Linux compatible (mostly), so I prefer that environment. Here are the details on how to make a cygwin32 application on a cygwin64 install:
1)install cygwin32-gcc package and the cygwin32-w32api-runtime package in cygwin64 setup, if you have not already done this. this will install a c compiler i686-pc-cygwin-gcc and the runtime cygwin1.dll that you will need to test your program (or you can test it in a cygwin32 install).
2) assuming your hello.c program above is to be compiled, select the C compiler and runtime, from the cygwin64 shell by using export CC, or just execute the C compiler as the default make output shows below "make hello":
$ export CC=i686-pc-cygwin-gcc
$ make hello
i686-pc-cygwin-gcc hello.c -o hello
$ ./hello
$ *There is no output, program didn't work*
3) you will note that nothing really happens because Cygwin runtime for 32 bit is not in the path. So add it to the path, and it will execute correctly
$ export PATH=/usr/i686-pc-cygwin/sys-root/usr/bin:$PATH
$ ./hello
Hello, world!
$
4) Sit back, have a sip of coffee, and rejoice
Cygwin provides packages containing cygwin-to-cygwin cross toolchains. There are cygwin32-* packages for building 32-bit from 64-bit Cygwin and cygwin64-* packages for building 64-bit from 32-bit Cygwin.
I've never used them, but I assume they work pretty much as any cross toolchain, so you should pass correct --host and --build arguments to your ./configure step.
Adding -m32 to the compiler does not make it select the correct libraries. You should check you have the i686-pc-cygwin-gcc compiler installed. To use that compiler you have to do something like this:
./configure --target=i686-pc-cygwin
Hope it helps :-)
Update December 2022
All other solutions in this thread no longer work !!!
Apparently, Cygwin no longer has packages to install 32-Bit compiler and required libraries!
Legacy "Cygwin32" (setup-x86.exe) can only be installed by passing the following option to the setup program, otherwise the installer terminates immediately with obscure error message:
--allow-unsupported-windows
Also, because the 32-Bit installation packages no longer are available on the "official" mirrors, we must manually use the Cygwin Time Machine mirror at:
http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457
This way we get a working 32-Bit gcc with all required libraries 😏
Note: Cygwin32 can be installed side-by-side with Cygwin64 (in a separate dir) without problem.
I am using Fedora 28 with Eclipse Version: Oxygen.3a.
I have already installed the add-on for LLVM-Clang from "Install new software". I am using GCC/G++ 8.1.1.
I built Clang using ninja build system, and it works perfectly fine from command line. I am interested in LibTooling library, so, it serves my purpose. Then, I was trying to setup Eclipse with Clang (mainly for easy debugging), but it Eclipse always gives me linker errors.
I tried 2 solutions:
Followed this thread Unable to install LLVM toolchain for Eclipse CDT. I made a hello world project, and I get the errors:
clang++ -I/home/hassan/Tools/llvm-clang/llvm/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -std=c++0x -o src/clang_test.bc ../src/clang_test.cpp
clang++ -L/usr/lib/gcc/x86_64-redhat-linux/8/32/ -L/home/hassan/Tools/llvm-clang/build/bin -o clang_test src/clang_test.bc -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc.a when searching for -lgcc
I set the include paths/lib paths to my already built (ninja build system) directory. It compiles fine without any problems, but I get linker errors, e.g., llvm::outs() could not be identified.
If anyone can point me in the right direction, that would be great.
Thanks.
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?
I have a very similar issue to the one presented in how to dynamically link to local copy of libc.so.6, libstdc++.so.6 on system with old version of gcc and I followed the answer provided there. To summarize, the issue is that I have code written using C++11 and the cluster sysadmin won't upgrade the gcc compiler to a version which supports C++11. I did a manual install of gcc4.9 in my home directory (using --prefix=$HOME). I compile my code with the following flags:
-I/home/stroberg/include -L/home/stroberg/lib -lc -lstdc++ -llapack -lblas -O3 -std=C++11
I also set
export LD_LIBRARY_PATH=/home/stroberg/lib:$LD_LIBRARY_PATH
The compilation goes fine until it gets to the linking stage, where I get the following errors:
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /home/stroberg/lib/libgcc_s.so when searching for -lgcc_s
Any ideas what could be causing the problem? I'm also using the armadillo package (also a local version) is that makes any difference.
Thanks.
I got it working, so I figured I should post what I did. Compiling with
-I$(HOME)/include -L$(HOME)/lib -lblas -llapack -lgsl -lglsblas -O3 -std=c++11
seemed to do the trick. Wish I knew exactly what fixed the problem, but I hope this helps.