Aug 19 2007, 04:07 PM
Post
#1
|
|
![]() Group: Members Posts: 2,350 Joined: 30-July 06 Member No.: 10,575 |
I'm starting to hopefully code a game for the Z, but I need to put stuff not only in multiple .hpp files but also in .cpp files. Does anybody have a good link for how to do this? My horrible searching skills failed to turn anything up.
Also, is there a good tutorial for using the autotools/makefiles? Those seem to be important to using multiple source files as well. Thanks. |
|
|
|
![]() |
Aug 19 2007, 06:01 PM
Post
#2
|
|
![]() Group: Members Posts: 2,350 Joined: 30-July 06 Member No.: 10,575 |
Ah, that mostly clears it up. A couple of follow-up questions:
1. So I make a prototype function in the header ( void myfunction(int myint); ), then have the complete function in the .cpp file? (Yes, as it works) 2. How do I use automake if I don't have a configure.in or configure.ac file? Thanks. EDIT: I'm getting errors when I try to compile with the files like they are: CODE Fish LOZR # g++ lozr.cpp sprite.cpp screen.cpp input.cpp -o lozr -lSDL -lSDL_image lozr.cpp: In function 'int main(int, char**)': lozr.cpp:42: warning: deprecated conversion from string constant to 'char*' /tmp/ccXyIXFl.o:(.bss+0x0): multiple definition of `spriteMain' /tmp/cc2NlQAW.o:(.bss+0x20): first defined here /tmp/ccXyIXFl.o:(.bss+0x2c): multiple definition of `surfScreen' /tmp/cc2NlQAW.o:(.bss+0x4c): first defined here /tmp/ccEAhPKQ.o:(.bss+0x0): multiple definition of `surfScreen' /tmp/cc2NlQAW.o:(.bss+0x4c): first defined here /tmp/ccxIcIsw.o:(.bss+0x0): multiple definition of `myEvent' /tmp/cc2NlQAW.o:(.bss+0x0): first defined here collect2: ld returned 1 exit status Fish LOZR # What's wrong? This post has been edited by Capn_Fish: Aug 19 2007, 06:44 PM |
|
|
|
Aug 20 2007, 12:48 AM
Post
#3
|
|
|
Group: Members Posts: 138 Joined: 12-February 04 Member No.: 1,830 |
QUOTE(Capn_Fish @ Aug 20 2007, 02:01 AM) EDIT: I'm getting errors when I try to compile with the files like they are: CODE Fish LOZR # g++ lozr.cpp sprite.cpp screen.cpp input.cpp -o lozr -lSDL -lSDL_image lozr.cpp: In function 'int main(int, char**)': lozr.cpp:42: warning: deprecated conversion from string constant to 'char*' /tmp/ccXyIXFl.o:(.bss+0x0): multiple definition of `spriteMain' /tmp/cc2NlQAW.o:(.bss+0x20): first defined here /tmp/ccXyIXFl.o:(.bss+0x2c): multiple definition of `surfScreen' /tmp/cc2NlQAW.o:(.bss+0x4c): first defined here /tmp/ccEAhPKQ.o:(.bss+0x0): multiple definition of `surfScreen' /tmp/cc2NlQAW.o:(.bss+0x4c): first defined here /tmp/ccxIcIsw.o:(.bss+0x0): multiple definition of `myEvent' /tmp/cc2NlQAW.o:(.bss+0x0): first defined here collect2: ld returned 1 exit status Fish LOZR # What's wrong? If your .cpp files are #including the same header file, then the header file needs guards around it to stop it being included more than once. So for example, if your header is called header.h, you would have the following in it: CODE #ifndef HEADER_H #define HEADER_H <usual header code> #endif This would then ensure that the header file is included only once during compilation. Dan |
|
|
|
Capn_Fish How To Use Multiple .cpp Files? Aug 19 2007, 04:07 PM
koan QUOTE(Capn_Fish @ Aug 19 2007, 04:07 PM)I... Aug 19 2007, 04:14 PM
Capn_Fish Thanks for the quick reply. How do I make function... Aug 19 2007, 04:58 PM
Meanie QUOTE(Capn_Fish @ Aug 20 2007, 10:58 AM)Thank... Aug 19 2007, 05:18 PM
koan QUOTE(Meanie @ Aug 19 2007, 05:18 PM)hpp file... Aug 20 2007, 06:25 PM
Meanie QUOTE(koan @ Aug 21 2007, 12:25 PM)QUOTE(Mean... Aug 20 2007, 06:40 PM
koan QUOTE(Meanie @ Aug 20 2007, 06:40 PM)http://f... Aug 20 2007, 10:51 PM
Capn_Fish I've done that, that's why I find this so ... Aug 20 2007, 06:24 AM
Capn_Fish I figured it out. I needed to use "extern (va... Aug 20 2007, 01:20 PM![]() ![]() |
|
Lo-Fi Version | Time is now: 20th June 2013 - 01:57 AM |