MinGW不构建和执行C ++

时间:2019-01-10 02:24:48

标签: c++ 64-bit mingw codelite

我在一个简单的hello世界中收到的完整错误是,代码是...

#include <iostream>

int main() {
    std::cout << "Hello, world!";
    return 0;
}

我下载了MinGW并安装了mingw32-base,mingw32-gcc-g ++和msys-base ...

我下载并安装了64位CodeLite,并在设置向导中选择了我的计算机,并在计算机中扫描了C ++编译器。 MinGW也在我的环境变量路径中。

C:\WINDOWS\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f  Makefile

"----------Building project:[ HelloWorld - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/owner/Documents/CPPWorkspace/HelloWorld'
C:/MinGW/bin/g++.exe  -c  "C:/Users/owner/Documents/CPPWorkspace/HelloWorld/main.cpp" -std=c++14 -Wall -g -O0 -Wall  -o ./Debug/main.cpp.o -I. -I.
In file included from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\cstdio:42,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ext\string_conversions.h:43,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\basic_string.h:6391,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\string:52,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\locale_classes.h:40,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\ios_base.h:41,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:42,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
             from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
             from C:/Users/owner/Documents/CPPWorkspace/HelloWorld/main.cpp:1:
c:\mingw\include\stdio.h:788:34: error: '__off64_t' does not name a type; did you mean '__time64_t'?
 typedef union { __int64 __value; __off64_t __offset; } fpos_t;
                              ^~~~~~~~~
                              __time64_t
mingw32-make.exe[1]: *** [Debug/main.cpp.o] Error 1
HelloWorld.mk:97: recipe for target 'Debug/main.cpp.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/owner/Documents/CPPWorkspace/HelloWorld'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====1 errors, 0 warnings====

有人知道我为什么无法构建和执行文件吗?

1 个答案:

答案 0 :(得分:0)

我已成功使用C:\MinGW\bin\g++ test.cpp -o test.exe命令构建了示例。

但是我建议您使用MinGW-w64,它是同时支持32位和64位编译的改进版本。