Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

undefined reference to `WinMain@16' xharbour+mingw

456 views
Skip to first unread message

rajko

unread,
May 25, 2013, 2:43:37 PM5/25/13
to
Hi, I am having undefined reference to `WinMain@16' error when I try to compile my project with xharbour which I compiled with mingw 4.7.1. Any suggestion is a appreciated.Rajko

rajko

unread,
May 25, 2013, 2:45:26 PM5/25/13
to
I forget to give you compiler output maybe will help.

> > c:/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.1/../../../../i686-w64-mingw3
>
> > 2/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0
>
> > x39): undefined reference to `WinMain@16'
>
>

Saulius

unread,
May 26, 2013, 4:31:44 AM5/26/13
to
Hi Rajko,

>> > c:/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.1/../../../../i686-w64-mingw3
>> > 2/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0
>> > x39): undefined reference to `WinMain@16'

It is your first program in mingw, right?
Can you show project lnk file to us?

Saulius


rajko

unread,
May 26, 2013, 7:05:44 AM5/26/13
to
Thank you Saulius for answering, yes this is my first mingw program the project file is as follows:


#BCC
VERSION=BCB.01

CC_DIR = C:/Tools/mingw
HB_DIR = C:/Tools/xharbour

RECURSE= NO

SHELL =
COMPRESS = NO
EXTERNALLIB = NO
XFWH = NO
FILESTOADD = 1
WARNINGLEVEL = 0
USERDEFINE =
USERINCLUDE =
USERLIBS =
EDITOR = notepad
CGI = NO
GUI = NO
MT = NO
SRC02 = obj
PROJECT = project.exe $(PR)

OBJFILES = $(SRC02)/prg1.o //
$(SRC02)/prg2.o $(OB)

PRGFILES = src/prg1.PRG //
src/prg2.PRG $(PS)

OBJCFILES = $(OBC)
CFILES = $(CF)
RESFILES =
RESDEPEN =
TOPMODULE = prg1.PRG
LIBFILES = -Wl,--allow-multiple-definition -Wl,--start-group -lvm -lrtl -lpcrepos -lgtwin -llang -lrdd -lrtl -lvm -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhsx -lhbsix -lcommon -lcodepage -lm -lct -ldebug -Wl,--end-group
EXTLIBFILES =
DEFFILE =
HARBOURFLAGS = -m -b -p -w0
CFLAG1 = $(SHELL) -I$(HB_DIR)/include -c -Wall
CFLAG2 = -L$(HB_DIR)/lib -L$(CC_DIR)/lib
RFLAGS =
LFLAGS = $(CFLAG2)
IFLAGS =
LINKER = gcc

ALLOBJ = $(OBJFILES) $(OBJCFILES)
ALLRES = $(RESDEPEN)
ALLLIB = $(USERLIBS) $(LIBFILES) -luser32 -lwinspool -lgdi32 -lcomctl32 -lcomdlg32 -lole32 -loleaut32 -luuid -lmpr -lwsock32 -lws2_32 -lmapi32 -lwinmm
.autodepend

#DEPENDS

#COMMANDS
.cpp.o:
$(CC_DIR)\bin\gcc $(CFLAG1) $(CFLAG2) -o$* $**

.c.o:
$(CC_DIR)\bin\gcc -I$(HB_DIR)/include $(CFLAG1) $(CFLAG2) -I. -o$* $**

.prg.o:
$(HB_DIR)\bin\harbour -D__EXPORT__ -n -go -I$(HB_DIR)/include $(HARBOURFLAGS) -o$* $**

#BUILD

$(PROJECT): $(CFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(CC_DIR)\bin\$(LINKER) @&&!
$(PROJECT)
$(ALLOBJ)
$(LFLAGS)
$(ALLLIB)
!

Saulius

unread,
May 26, 2013, 11:23:45 AM5/26/13
to
Hi Rajko,

This undefined reference assumes, that no startup module included in obj list
First module must be \obj\gc\mainstd.o or \obj\gc\mainwin.o, dependent on used GUI
I don't use mingw, so can't help more deeply :(
Try this advice...

Saulius


rajko

unread,
May 26, 2013, 3:56:01 PM5/26/13
to
Thanks for the effort Saulius but IMHO (very humble :)) I think that the reason compiler throws me an error is explaind on this link

http://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16

To cut the long things short :) gcc search for the main and if it doesn't find it then looks for WinMain which he cannot find because is not there. I made project like above with just 2 files prg1.prg i prg2.prg with content that follows

prg1.prg:

*****************************
FUNCTION main ()

CLEAR SCREEN

@ 7,5 SAY "from main()"

DO procSub

RETURN 0


prg2.prg:

PROCEDURE procSub

@ 10,5 SAY "from subProc"

RETURN


I only had to add libdebug in the project to get rid off unreferenced DBGENTRY error and stay with only unreferenced WinMain error. But when I think of it wouldn't this minimal program should work out of box. Maybe I picked wrong version of compiler I downloaded it from

http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.1/32-bit/threads-win32/sjlj/

I'm siting for hours questioning everything to find solution which is probbably in front of me but I don't know enough to make sanse of it. Anyway thanks again.

Saulius

unread,
May 27, 2013, 4:57:02 AM5/27/13
to
Hi Rajko

I want only repeat my last advice:
include \obj\gc\mainstd.o in your project OBJ FILES chain

Saulius


rajko

unread,
May 27, 2013, 9:27:29 AM5/27/13
to
>I want only repeat my last advice:
>
> include \obj\gc\mainstd.o in your project OBJ FILES chain
>

Saulius, thank you very much, it worked. First time when I compiled xharbour I deleted obj folder and transferred only lib, bin and include folder so when you told me about mainstd.o i didn't found it. Now, you were good enough to see that I'm stubborn fool :) so stubbornly thanks again. Tell me, I thought that these files are only temporary and that they are part of .a files in lib folder, is it usual to reference these files in project?

cul...@gmail.com

unread,
May 27, 2013, 10:11:10 AM5/27/13
to
Hi rajko

i suggest to use msvc or borland c in place os mingw.

Regards
Luiz

dlzc

unread,
May 27, 2013, 1:16:37 PM5/27/13
to
Dear rajko:

On Monday, May 27, 2013 6:27:29 AM UTC-7, rajko wrote:
...
> Tell me, I thought that these files are only
> temporary and that they are part of .a files
> in lib folder, is it usual to reference these
> files in project?

Incorporating .o or .obj files into a library:
- packages like / linked modules in a single package, and
- resolves links that point within the library, for library code.

No requirement that they be libs. It is "usual" for them to be libs, yes. Sometimes you just need to capture and redirect function pointers... for special purposes. And you don't need to alter an entire lib to do it.

David A. Smith

rajko

unread,
May 27, 2013, 5:16:59 PM5/27/13
to

> i suggest to use msvc or borland c in place os mingw.

Please explain me why borland, it's not maintained anymore, mingw at least is. And when I'm wasting your time :) can I compile xharbour with Visual C++ 2010 Express?

Enrico Maria Giordano

unread,
May 27, 2013, 5:19:58 PM5/27/13
to
Rajko,

> Please explain me why borland, it's not maintained anymore,

It is, as far as I know. Latest version is 6.60 of 2013.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic


rajko

unread,
May 27, 2013, 5:24:40 PM5/27/13
to

> Incorporating .o or .obj files into a library:
>
> - packages like / linked modules in a single package, and
>
> - resolves links that point within the library, for library code.
>
> No requirement that they be libs. It is "usual" for them to be libs, yes. >Sometimes you just need to capture and redirect function pointers... for special >purposes. And you don't need to alter an entire lib to do it.

Yes I think that I understand what are you trying to say (an I didn't know that), but I was asking exclusively for xharbour. Does generated obj folder contains (obviously not entirely mainstd.o for example) but mostly, parts of .a files in lib folder?

rajko

unread,
May 27, 2013, 5:26:30 PM5/27/13
to
>
> It is, as far as I know. Latest version is 6.60 of 2013.
>

Sorry I'm stuck with bcc 5.5 for years :), I'll look for update.Thanks.

rajko

unread,
May 27, 2013, 6:41:44 PM5/27/13
to
> It is, as far as I know. Latest version is 6.60 of 2013.
>
Thanks. It works and it's fast, very fast :)

dlzc

unread,
May 28, 2013, 12:49:33 AM5/28/13
to
Dear rajko:

On Monday, May 27, 2013 2:24:40 PM UTC-7, rajko wrote:
...
> Yes I think that I understand what are you
> trying to say (an I didn't know that), but I
> was asking exclusively for xharbour. Does
> generated obj folder contains (obviously not
> entirely mainstd.o for example) but mostly,
> parts of .a files in lib folder?

I cannot say. With dozens of contributors, what the "exclusive forever" answer could be. Like mining in Minecraft, you find treasure where you find it.

David A. Smith

Otto Haldi

unread,
May 28, 2013, 5:56:28 AM5/28/13
to
On Mon, 27 May 2013 15:41:44 -0700 (PDT), rajko <dra...@yahoo.com> wrote:

>> It is, as far as I know. Latest version is 6.60 of 2013.
>>
>Thanks. It works and it's fast, very fast :)

Small question,
to move from 5.5 to 6.0 did you only remplace the \bcc55 to \bcc66 directory?
Regards
Otto

rajko

unread,
May 28, 2013, 6:55:01 AM5/28/13
to
>Small question,
>to move from 5.5 to 6.0 did you only remplace the \bcc55 to \bcc66 directory?

Also you have to edit bcc32.cfg and ilink32.cfg files in bin folder of bcc but that's the same as in bcc 5.5. Rajko

Otto Haldi

unread,
May 28, 2013, 2:48:03 PM5/28/13
to
Many thanks for your help.
Strange, the function HB_Compiler() still show me Borland C++ 5.5.1 !..

Enrico Maria Giordano

unread,
May 28, 2013, 3:44:24 PM5/28/13
to
Otto,

> Strange, the function HB_Compiler() still show me Borland C++ 5.5.1 !..

Probably because you are using an older xHarbour version.

Saulius

unread,
May 29, 2013, 3:57:44 AM5/29/13
to
Hi Rajko,

>> include \obj\gc\mainstd.o in your project OBJ FILES chain

> Tell me, I thought that these files are only temporary and that they are part of .a files in lib folder,
> is it usual to reference these files in project?

After last builds you don't need to include mentioned file (and maybe all obj files)
into your project using MinGW

Saulius


Otto Haldi

unread,
Jun 2, 2013, 3:04:14 AM6/2/13
to
On Tue, 28 May 2013 21:44:24 +0200, "Enrico Maria Giordano" <e.m.gi...@emagsoftware.it> wrote:

>> Strange, the function HB_Compiler() still show me Borland C++ 5.5.1 !..
>Probably because you are using an older xHarbour version.
I downloaded the new build from whosaway. Now every thing work well.
Thanks for you help.
0 new messages