对于上下文,我尝试使用Linux机器将源代码编译为Windows的32位可执行文件。我通过apt-get
使用了当前mingw-w64。这是我尝试编译ftp://ftp.thegpm.org/projects/tandem/source的项目。更具体地说,17-02-01
zip文件包含我感兴趣的来源。
我的第一次尝试是使用Makefile_ubuntu
下的tandem-linux
进行修改,并使用mingw
提供的内容替换gcc,并通过添加{{1}来修复标题引用问题} #includes
文件丢失了错误。超级hacky。有人能告诉我一条更光明的道路吗?
这是我使用的makefile:
.cpp
这是错误:
#makefile for c++ programs
#change the name of the executable to use for "any" project
EXECUTABLE = ../bin/tandem.exe
#EXECUTABLE = ../bin/p3.exe
LINKCC = $(CXX)
#CXXFLAGS denotes flags for the C++ compiler
CXX = /usr/bin/i686-w64-mingw32-g++-win32
#uncomment this line if you are using gcc 4.x
CXXFLAGS = -m32 -std=gnu++11
#CXXFLAGS = -w -O2 -DGCC4_3
#CXXFLAGS = -w -O2 -DGCC4_3 -DX_P3
#ubuntu 64 bit version
#LDFLAGS = -L/usr/lib/x86_64-linux-gnu/libexpat.a
LDFLAGS = -lpthread -lm -L/usr/lib/x86_64-linux-gnu/libexpat.a
#LDFLAGS = -lpthread -L/usr/lib -lm -lexpat
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
DEPS := $(patsubst %.o,%.d,$(OBJS))
all: $(EXECUTABLE)
#define the components of the program, and how to link them
#these components are defined as dependencies; that is they must be up-to-date before the code is linked
$(EXECUTABLE): $(DEPS) $(OBJS)
$(LINKCC) $(CXXFLAGS) -o $(EXECUTABLE) $(OBJS) $(LDFLAGS)
#specify the dep files depend on the cpp files
%.d: %.cpp
$(CXX) -M $(CXXFLAGS) $< > $@
$(CXX) -M $(CXXFLAGS) $< | sed s/\\.o/.d/ > $@
clean:
-rm $(OBJS) $(EXECUTABLE) $(DEPS) *~
explain:
@echo "The following info represents the program:"
@echo "Final exec name: $(EXECUTABLE)"
@echo "Source files: $(SRCS)"
@echo "Object files: $(OBJS)"
@echo "Dep files: $(DEPS)"
depend: $(DEPS)
@echo "Deps are now up-to-date."
-include $(DEPS)