[wellylug] C++ Programing Problem

Jethro Carr dodocaptain at paradise.net.nz
Sun Sep 7 13:59:21 NZST 2003


Hi,
Has anyone here got good c++ programing knowledge?

I've got a Makefile problem, on two files which both need 1 header

There are 2 cpp files : main.cpp & jgame2d.cpp
Jgame2d.cpp has a header (jgame2d.h) which contains stuff for the game
library.

The structure is:

main.cpp                   >>> main.h
                                      jgame2d/jgame2d.h

jgame/jgame2d.cpp    >>>  jgame2d/jgame2d.h

The code is all correct (it does have a few warnings...), the problem is
that the compiler thinks that everything in jgame2d.h has been defined
twice, by main.cpp & jgame2d.cpp (as they both use that file)


gcc -Wall -ansi main.cpp jgame2d/jgame2d.cpp -o main -lGL -lGLU `sdl-config --cflags --libs`
In file included from main.cpp:30:
jgame2d/jgame2d.h:52:7: warning: no newline at end of file
In file included from jgame2d/jgame2d.cpp:30:
jgame2d/jgame2d.h:52:7: warning: no newline at end of file
jgame2d/jgame2d.cpp:165:2: warning: no newline at end of file
/tmp/ccEE8s0W.o(.bss+0x0): multiple definition of `keyboard_state'
/tmp/cc5N5aQs.o(.bss+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [all] Error 1

Does anyone know how to fix this problem? I think it's a simple
solution, but I don't know it....:(


-thanks



--- Jethro

dodocaptain at paradise.net.nz
homepages.paradise.net.nz/jethroc/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20030907/85eebffc/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smiley-6.png
Type: image/png
Size: 796 bytes
Desc: not available
Url : http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20030907/85eebffc/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: text/x-makefile
Size: 164 bytes
Desc: not available
Url : http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20030907/85eebffc/attachment.bin 


More information about the wellylug mailing list