C++ 交叉编译Webots控制器

C++ 交叉编译Webots控制器,c++,makefile,mingw,cross-compiling,webots,C++,Makefile,Mingw,Cross Compiling,Webots,我正在尝试使用MinGW从Linux到Windows交叉编译Webots()的机器人控制器(.exe) Webots提供了一个所有平台通用的文件,该文件为编译准备了构建环境(必要的依赖项): 我当前的makefile,其中我根据MinGW和我的webots安装设置了几个变量: WEBOTS_HOME = /usr/share/webots/resources/windows_home #WEBOTS_HOME = /usr/share/webots RESOURCES_PATH = $(WEB

我正在尝试使用MinGW从Linux到Windows交叉编译Webots()的机器人控制器(.exe)

Webots提供了一个所有平台通用的文件,该文件为编译准备了构建环境(必要的依赖项):

我当前的makefile,其中我根据MinGW和我的webots安装设置了几个变量:

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)

 # ---------------------------------------------------
另外,我已经在我的Windows设备上安装了Webots,并将安装文件夹复制到Linux设备上的安装文件夹中,这样我就可以访问预编译的Windows库

问题是当链接器尝试查找两个库时(
-lccontroller
-lCppController
,它们附加在
Makefile.include
)中:

从我收集的资料来看,这个问题通常是在尝试将32位库链接到64位二进制文件时引起的(反之亦然),但我的makefile或
makefile.include上没有
-m32
-m64
标志。我的OSs都是64位的,所以我认为库的类型应该没有任何问题

我尝试过使用Webots的本机linux安装文件夹,但遇到了类似的问题:

# 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
这很奇怪,因为
libController.so
libcppccontroller.so
都存在于
/usr/share/webots/lib/


那么我到底错过了什么呢?

一个有趣的问题。我和Webots合作多年,但从未尝试过。一点也不确定,但不会,因为您应该使用libController.dll文件(windows one)而不是libController.so(linux one)。
# 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