【问题标题】:MinGW won't compile, Error 1MinGW 无法编译,错误 1
【发布时间】:2012-04-01 00:58:52
【问题描述】:

用 c++ 制作一个简单的 hello world 应用程序,但它不会编译。我有文件夹C:\WiiGames\e3\ 和文件main.cppMakefile。我的makefile是:

build: main.cpp
    C:/MinGW/bin/g++.exe main.cpp -o e3.exe

我的错误是:

C:\WiiGames\e3>make build
C:/MinGW/bin/g++.exe main.cpp -o e3.exe
make: *** [build] Error 1

C:\WiiGames\e3>

任何帮助将不胜感激。

我的代码:

#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <cstdlib>
#include <time.h>

int main() {
    printf("Hello World!");
}

g++ -v:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)

【问题讨论】:

  • 如果你提供你的代码会更容易回答。

标签: c++ makefile mingw


【解决方案1】:

确保它是一个制表符而不是 make 文件中 c:/mingw... 行之前的空格。看起来它是在给出错误,而不是 g++。

【讨论】:

  • 确实是一个标签。从命令行运行构建命令没有输出,所以我认为它是 g++。
  • 如果你不传递命令行,g++ 会输出任何东西吗?或者只是运行“g++ -v”来获取版本信息?除了 main 通常被声明为“int main(int argc, char *argv[])”这一事实之外,您的代码看起来还不错。应该是 mingw 的设置问题。
  • g++ -v 添加在上面。如果我只运行 g++,它会显示:g++: fatal error: no input files compilation terminate。如果我从命令行构建,我会得到 1 个空白行并退出。
【解决方案2】:

直接在命令行运行g++.exe main.cpp -o e3.exe会发生什么?如果什么都没发生,g++ 在你的路径中吗?我首先要确保 g++ 已设置并在您的路径中。

【讨论】:

  • 绝对没有。我今天重新安装了 MinGW。
猜你喜欢
  • 2015-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-13
  • 2013-04-25
  • 2017-01-18
  • 2018-11-16
  • 1970-01-01
相关资源
最近更新 更多