在cygwin中编译新的mingw二进制文件

Compiling in cygwin with new mingw binaries

本文关键字:mingw 二进制文件 编译 cygwin      更新时间:2023-10-16

我更新了我的mingw二进制文件以支持c++11,现在我无法编译我的代码。

我正在使用cygwin,并将二进制文件包含在PATH环境变量中。

这是我的include和main的第一行:

#include "icm/icmCpuManager.hpp"
#include "Instruction.hpp"
#include "MicroblazeInstruction.hpp"
#include "CpuManager.hpp"
#include "File.hpp"
#include "Utils.hpp"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <sstream>
#include <cstdint>

将我带到File.hpp

中的第一行
#ifndef FILE_HPP
#define FILE_HPP
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <sstream>
#include <cstdint>

这是我的makefile:

IMPERAS=$(IMPERAS_HOME)
ifndef IMPERAS
  IMPERAS := $(error "IMPERAS paths not defined")
endif
SUFFIX=.cpp
CC=g++
CFLAGS=-O2 -Wall -c -I $(IMPERAS_HOME)/ImpPublic/include/host/ -std=c++11
LDFLAGS=-m32 -L$(IMPERAS_HOME)/bin/$(IMPERAS_ARCH) -lRuntimeLoader  
EXECUTABLE=./faith.exe
SRC=./main.cpp ./CpuManager.cpp ./Instruction.cpp ./File.cpp ./Utils.cpp
OBJS=$(SRC:.cpp=.o)
DEPS=
#SHAREDOBJ=$(SRC:.c=.so)
.PHONY: all
#all: $(EXECUTABLE) $(SHAREDOBJ)
all: $(EXECUTABLE)
# platform
$(EXECUTABLE): $(OBJS)
    @    echo "# Linking Platform $@"
    $(V) $(CC) $(OBJS) $(LDFLAGS) -o $@
# platform objects
%.o: %.cpp $(DEPS)
    @    echo "# Compiling Platform source: $@"
    $(V) $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@
# dynamic lib
#$(SHAREDOBJ): $(OBJS)
#   @    echo "# Host Linking Platform object $@"
#   $(V) $(CC) -shared -o $@ $^ $(LDFLAGS) 
.PHONY: clean
clean:
    $(V) - rm -f $(EXECUTABLE) $(OBJS)
这是我的编译错误:
$ make
# Compiling Platform source: main.o
g++ -m32 -LC:Imperas/bin/Windows32 -lRuntimeLoader   -O2 -Wall -c -m32 -I C:Imperas/ImpPublic/include/host/ -std=c++11 main.cpp -o main.o
In file included from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/ios_base.h:43:0,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ios:43,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ostream:40,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/iostream:40,
                 from File.hpp:4,
                 from main.cpp:5:
c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/locale_classes.h:45:1: error: expected unqualified-id before 'namespace'
In file included from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/cwctype:52:0,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/locale_facets.h:41,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/basic_ios.h:39,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ios:45,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ostream:40,
                 from c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/iostream:40,
                 from File.hpp:4,
                 from main.cpp:5:
c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected '}' before end of line
c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected unqualified-id before end of line
c:mingwmingw64bin../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected declaration before end of line
makefile:29: recipe for target 'main.o' failed
make: *** [main.o] Error 1

您在文件"CpuManager.hpp"末尾缺少分号

缺少的分号会在紧接分号的代码中触发错误,该错误会在编译器错误中识别。