【问题标题】:MinGW not Building and Executing C++MinGW 不构建和执行 C++
【发布时间】:2019-01-10 02:24:47
【问题描述】:

我在一个简单的 hello world 上收到的完整错误是,代码是...

#include <iostream>

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

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

我下载并安装了 CodeLite 64 位,并在安装向导中扫描了我的计算机以查找 C++ 编译器并选择了 MinGW。 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====

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

【问题讨论】:

  • 你的makefile中有什么?您是否尝试使用 g++ 编译示例?

标签: c++ 64-bit mingw codelite


【解决方案1】:

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

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

【讨论】:

  • 有些设置看起来很奇怪,Threads [posix, win32], Exception [dwarf, sjlj] 这个仓库安全吗?
  • @KyleGoertzen,一般选择 x86_64-posix-seh
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-09
  • 2012-02-05
  • 1970-01-01
  • 2013-02-28
  • 2023-01-30
  • 2013-06-17
  • 2015-12-31
相关资源
最近更新 更多