mingw: undefined reference to `WinMain@16' [message #482026] |
Tue, 25 August 2009 07:36 |
Eclipse User |
|
|
|
Originally posted by: outskywind.hotmail.com
I am new to eclipse cdt, i installed the mingw and the eclipse c/c++
ide as reccomended , and set the bin in path right . However, i can get
the toolchain configured with eclipse , when i am compiling an easy c++
project to check it out, i got the problem:
here is the c++ projet :
#include <iostream>
using namespace std;
int main(void) {
cout << "hello, word" << endl;
return 0;
}
and the error shows £ºC:\MinGW\lib/libmingw32.a(main.o):main.c: undefined
reference to `WinMain@16'.
how can i get rid of this problem? and anyone who have eclipse with mingw
worked successfully could give me a detail guide how to set them ? i would
appreciate it very much!
my email : outskywind@hotmail.com.
|
|
|
|
|
|
Re: mingw: undefined reference to `WinMain@16 ' [message #482550 is a reply to message #482202] |
Thu, 27 August 2009 02:04 |
Eclipse User |
|
|
|
Originally posted by: outskywind.hotmail.com
i see that if i build the excutable c++ project , it will work well,and
it says " --library = mingw32 ". while when i build the makefile c++
project , i add that "creat makefile automatically" option.
in the objects.mk file the "LIBS := "is empty ,is this cause the error?
and someone says you should install Msys too if want to build makefile c++
project, is that ture ? and do you mean that i should write the makefile
myself?
|
|
|
|
Re: mingw: undefined reference to `WinMain@16 ' [message #482795 is a reply to message #482722] |
Fri, 28 August 2009 02:28 |
Eclipse User |
|
|
|
Originally posted by: outskywind.hotmail.com
Ah, in the properties menu,click the "c/c++ construction" mode , i see
"generate makefile" option.
yeah, i made the makefile myself,and it works :
CXXFLAGS = -O2 -g -Wall -fmessage-length=0
OBJS = say.o
LIBS =
TARGET = say.exe
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
and the eclipse console shows:
make all
g++ -O2 -g -Wall -fmessage-length=0 -c -o say.o say.cpp
g++ -o say.exe say.o
but,if i add "#pragma comment(linker, "/subsystem:console") " in my
sourcefile,without my makefile but using the"generate makefile
automatically" option,it works well too. so i have the idea there is
something missing in g++ link flags by default, and i saw someone add
"-Wl,-subsystem,console" as g++ link flag, what's that? and how could i
set the g++ link as console project,not win32 project.
thanks very much.
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04586 seconds