简体   繁体   English

MinGW不构建和执行C ++

[英]MinGW not Building and Executing C++

The full error I'm receiving on a simple hello world is, and the code is... 我在一个简单的hello世界上收到的完整错误是,代码是...

#include <iostream>

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

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

I downloaded and installed CodeLite 64 bit and scanned my computer for a C++ compiler in the setup wizard and selected MinGW. 我下载并安装了64位CodeLite,并在安装向导中扫描了我的计算机,寻找C ++编译器,然后选择了MinGW。 MinGW is also in my Path in the Environment Variables. 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====

Does anyone understand why I am unable to build and execute the file? 有谁知道为什么我无法生成和执行文件?

I successfully build your sample with C:\\MinGW\\bin\\g++ test.cpp -o test.exe command. 我使用C:\\MinGW\\bin\\g++ test.cpp -o test.exe命令成功构建了示例。

However I recommend you go with MinGW-w64 which is improved version that supports both 32bit and 64bit compilation. 但是我建议您使用MinGW-w64 ,它是同时支持32位和64位编译的改进版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM