0

重複の可能性:
mingwを使用したEclipseでのWinMainへの未定義の参照エラー1

「c/c++ 開発ガイド」の下にある「はじめに」のヘルプを読んでいて、メイクファイルで行き詰っています...それほど遠くありません。私は c または c++ は初めてではありませんが、eclipse と makefile は初めてです。

Hereにアクセスして wascana setup.exe をダウンロードし、それを実行してインストールしました。ヘリオスリリースです。私もWindows 7を実行しています。

「hello world」テンプレートを作成して実行することができたので、少し試してみました。しかし、今はメイクファイルのチュートリアルに従っていますが、プロジェクトがビルドされません。次のエラーが表示されます。

make all
g++ -g -o hello main.o
c:/wascana/mingw/bin/../lib/gcc/mingw32/4.4.1-dw2/../../../libmingw32.a(main.o):main.c:
(.text+0xd2): undefined reference to 'WinMain@16'
collect2: ld returned 1 exit status
make: *** [hello.exe] Error 1

私は指示に忠実に従い、すべてに同じ名前を付けました。戻って、動作が同じであることを確認するためにできることをコピー/貼り付けましたが、それでもビルドしません。

編集: ここに main.cpp があります

#include
using namespace std;

int main () {
// Say Hello five times
for (int index = 0; index < 5; ++index)
cout << "HelloWorld!" << endl;
char input = 'i';
cout << "To exit, press 'm'" << endl;
while(input != 'm') {
cin >> input;
cout << "You just entered " << input
<< " you need to enter m to exit." << endl;
}
exit(0);
}

そして、これがmakeファイルです(ただし、適切なタブが配置されています)。

all: hello.exe
clean:
rm main.o hello.exe
hello.exe: main.o
g++ -g -o hello main.o
main.o:
g++ -c -g main.cpp

編集:

とった..

と入力したとき、私はそれが奇妙だと思いましたexit(0)。に切り替えたところreturn(0)、正常に動作するようになりました。

お時間をいただきありがとうございました。

4

0 に答える 0