Forum Post
Index > Lgi > Example helloworld project, please...

Author/Date Example helloworld project, please...
_Vi
01/03/2007 12:02am
Could you put into documentation or somewhere an example "Just an emplty window" or similar project which will:
1. Be compliled and work in Linux, Cygwin and VC++;
2. Demonstrate which way of writing Lgi applications is correct. (E.g. how to write correct main function, what headers include, what should Makefile contain...)?

P.S. I've tried create an helloworld app myself using Lgi/readme.txt and Lgi/docs/html/index.html guidelines, and after some modification (notably -i$(LGIDIR)/include/linux/X -> -I$(LGIDIR)/include/win32) ran into underwritten problem:

lgitest.o:lgitest.cpp:(.rdata$_ZTV8MyWindow[vtable for MyWindow]+0x20): undefined reference to `GView::NameW(unsigned int*)'

P.P.S. Sorry for possibly incorrect English

The attempt to create helloworld:
# Makefile:

CXX=g++
CFLAGS=
LGIDIR=/d/e/progs/code/Lgi
LINKAGAINST= -llgid -L$(LGIDIR)/DebugX
INCLUDES=-I$(LGIDIR)/include/common -I$(LGIDIR)/include/win32

all: lgitest

lgitest: lgitest.o
$(CXX) $(CFLAGS) $(LINKAGAINST) lgitest.o -o lgitest

lgitest.o: lgitest.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -c lgitest.cpp -o lgitest.o

# End of Makefile

lgitest.cpp:
#include "Lgi.h" // As recommended in readme.txt

class MyWindow : public GWindow
{
public:
/*virtual char16 * NameW ( )
{
//return 0;
}

virtual bool NameW (unsigned int *n){
return false;
}*/ // It is a weak attemp to pass throw that error message

MyWindow()
{
GRect r(0, 0, 700, 600);
# Taken completely from example in Lgi/docs/html/index.html
}


};


int LgiMain(OsAppArguments &Args)
{
# Taken completely from example in Lgi/docs/html/index.html
}
# End of lgitest.cpp

V@vi-winxp ~/code/Lgi
$ make CXX=/usr/bin/g++
/usr/bin/g++ -I/d/e/progs/code/Lgi/include/common -I/d/e/progs/code/Lgi/include/win32 -c lgitest.cpp -o lgitest.o
In file included from /d/e/progs/code/Lgi/include/common/Lgi.h:236,
from lgitest.cpp:1:
/d/e/progs/code/Lgi/include/common/Gdc2.h:197: warning: malformed '#pragma pack(push[, id], <n>)' - ignored
/d/e/progs/code/Lgi/include/common/Gdc2.h:462: warning: #pragma pack (pop) encountered without matching #pragma pack (push, <n>)
In file included from /d/e/progs/code/Lgi/include/common/Lgi.h:236,
from lgitest.cpp:1:
/d/e/progs/code/Lgi/include/common/Gdc2.h:507: warning: malformed '#pragma pack(push[, id], <n>)' - ignored
/d/e/progs/code/Lgi/include/common/Gdc2.h:532: warning: #pragma pack (pop) encountered without matching #pragma pack (push, <n>)
/usr/bin/g++ -llgid -L/d/e/progs/code/Lgi/DebugX lgitest.o -o lgitest
lgitest.o:lgitest.cpp:(.rdata$_ZTV8MyWindow[vtable for MyWindow]+0x20): undefined reference to `GView::NameW(unsigned int*)'
lgitest.o:lgitest.cpp:(.rdata$_ZTV8MyWindow[vtable for MyWindow]+0x468): undefined reference to `virtual thunk to GView::NameW(unsigned int*)'
lgitest.o:lgitest.cpp:(.rdata$_ZTC8MyWindow0_7GWindow[construction vtable for GWindow-in-MyWindow]+0x20): undefined reference to `GView::NameW(unsigned int*)'
lgitest.o:lgitest.cpp:(.rdata$_ZTC8MyWindow0_7GWindow[construction vtable for GWindow-in-MyWindow]+0x468): undefined reference to `virtual thunk to GView::NameW(unsigned int*)'
lgitest.o:lgitest.cpp:(.rdata$_ZTC8MyWindow0_5GView[construction vtable for GView-in-MyWindow]+0x20): undefined reference to `GView::NameW(unsigned int*)'
lgitest.o:lgitest.cpp:(.rdata$_ZTC8MyWindow0_5GView[construction vtable for GView-in-MyWindow]+0x458): undefined reference to `virtual thunk to GView::NameW(unsigned int*)'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):: undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
make: *** [lgitest] Error 1

V@vi-winxp ~/code/Lgi
$ /usr/bin/g++ --version
g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Reply