DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 18th October 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default Makefiles

Hello,

As I continue in my programming education, my programs are becoming increasingly large and complex. As a result I decided to start to learn how to write makefiles.

I wrote one up for project I'm working on. It had two header files and three .cpp files. When I went to make, I got a boatload of errors, such as methods already defined. I put all the .cpp files into one file, and it works fine. What gives? I can get away with one large .cpp file in this project, but my next one (final project) will be too large for one file.

I do have ifndef, defines for the header files. And each .cpp file called both header files. I don't know if that matters or not.

Here is the Makefile I wrote (didn't work - it did when it was reduced to one .cpp file):

Code:
hack_slash: main.o draw.o collision.o
	g++ main.o draw.o collision.o -o hack_slash -lcurses 

main.o: main.cpp
	g++ -c main.cpp

draw.o: draw.cpp
	g++ -c draw.cpp

collision.o: collision.cpp
	g++ -c collision.cpp

clean:
	rm *.o

Here are the errors I received:

Code:
g++ main.o draw.o collision.o -lcurses
draw.o: In function `thing::thing()':
draw.cpp:(.text+0x0): multiple definition of `thing::thing()'
main.o:main.cpp:(.text+0x0): first defined here
draw.o: In function `thing::thing()':
draw.cpp:(.text+0x6): multiple definition of `thing::thing()'
main.o:main.cpp:(.text+0x6): first defined here
draw.o: In function `thing::thing(int, int, char)':
draw.cpp:(.text+0xc): multiple definition of `thing::thing(int, int, char)'
main.o:main.cpp:(.text+0xc): first defined here
draw.o: In function `thing::thing(int, int, char)':
draw.cpp:(.text+0x34): multiple definition of `thing::thing(int, int, char)'
main.o:main.cpp:(.text+0x34): first defined here
draw.o: In function `thing::getx()':
draw.cpp:(.text+0x5c): multiple definition of `thing::getx()'
main.o:main.cpp:(.text+0x5c): first defined here
draw.o: In function `thing::gety()':
draw.cpp:(.text+0x66): multiple definition of `thing::gety()'
main.o:main.cpp:(.text+0x66): first defined here
draw.o: In function `thing::get_symbol()':
draw.cpp:(.text+0x72): multiple definition of `thing::get_symbol()'
main.o:main.cpp:(.text+0x72): first defined here
draw.o: In function `agent::agent(int, int, char)':
draw.cpp:(.text+0x80): multiple definition of `agent::agent(int, int, char)'
main.o:main.cpp:(.text+0x80): first defined here
draw.o: In function `agent::agent(int, int, char)':
draw.cpp:(.text+0xd8): multiple definition of `agent::agent(int, int, char)'
main.o:main.cpp:(.text+0xd8): first defined here
draw.o: In function `agent::get_velx()':
draw.cpp:(.text+0x130): multiple definition of `agent::get_velx()'
main.o:main.cpp:(.text+0x130): first defined here
draw.o: In function `agent::get_vely()':
draw.cpp:(.text+0x144): multiple definition of `agent::get_vely()'
main.o:main.cpp:(.text+0x144): first defined here
draw.o: In function `agent::set_alive(bool)':
draw.cpp:(.text+0x158): multiple definition of `agent::set_alive(bool)'
main.o:main.cpp:(.text+0x158): first defined here
draw.o: In function `agent::wall_collide()':
draw.cpp:(.text+0x170): multiple definition of `agent::wall_collide()'
main.o:main.cpp:(.text+0x170): first defined here
draw.o: In function `agent::wall_crash()':
draw.cpp:(.text+0x21c): multiple definition of `agent::wall_crash()'
main.o:main.cpp:(.text+0x21c): first defined here
draw.o: In function `agent::get_alive()':
draw.cpp:(.text+0x25e): multiple definition of `agent::get_alive()'
main.o:main.cpp:(.text+0x25e): first defined here
draw.o: In function `agent::get_prevx()':
draw.cpp:(.text+0x26e): multiple definition of `agent::get_prevx()'
main.o:main.cpp:(.text+0x26e): first defined here
draw.o: In function `agent::get_prevy()':
draw.cpp:(.text+0x2c4): multiple definition of `agent::get_prevy()'
main.o:main.cpp:(.text+0x2c4): first defined here
draw.o: In function `dot::dot(int, int, char)':
draw.cpp:(.text+0x31c): multiple definition of `dot::dot(int, int, char)'
main.o:main.cpp:(.text+0x31c): first defined here
draw.o: In function `dot::dot(int, int, char)':
draw.cpp:(.text+0x358): multiple definition of `dot::dot(int, int, char)'
main.o:main.cpp:(.text+0x358): first defined here
draw.o: In function `guard::guard(int, int, char)':
draw.cpp:(.text+0x394): multiple definition of `guard::guard(int, int, char)'
main.o:main.cpp:(.text+0x394): first defined here
draw.o: In function `guard::guard(int, int, char)':
draw.cpp:(.text+0x3ba): multiple definition of `guard::guard(int, int, char)'
main.o:main.cpp:(.text+0x3ba): first defined here
draw.o: In function `hackbot::hackbot(int, int, char)':
draw.cpp:(.text+0x3e0): multiple definition of `hackbot::hackbot(int, int, char)'
main.o:main.cpp:(.text+0x3e0): first defined here
draw.o: In function `hackbot::hackbot(int, int, char)':
draw.cpp:(.text+0x41c): multiple definition of `hackbot::hackbot(int, int, char)'
main.o:main.cpp:(.text+0x41c): first defined here
draw.o: In function `slashbot::slashbot(int, int, char)':
draw.cpp:(.text+0x458): multiple definition of `slashbot::slashbot(int, int, char)'
main.o:main.cpp:(.text+0x458): first defined here
draw.o: In function `slashbot::slashbot(int, int, char)':
draw.cpp:(.text+0x494): multiple definition of `slashbot::slashbot(int, int, char)'
main.o:main.cpp:(.text+0x494): first defined here
draw.o: In function `guard::get_distance(int, int, int, int)':
draw.cpp:(.text+0x526): multiple definition of `guard::get_distance(int, int, int, int)'
main.o:main.cpp:(.text+0x4d0): first defined here
draw.o: In function `guard::normalize_local_steer(float)':
draw.cpp:(.text+0x5a0): multiple definition of `guard::normalize_local_steer(float)'
main.o:main.cpp:(.text+0x54a): first defined here
draw.o: In function `guard::flee(int, int, float)':
draw.cpp:(.text+0x616): multiple definition of `guard::flee(int, int, float)'
main.o:main.cpp:(.text+0x5c0): first defined here
draw.o: In function `guard::seek(int, int, float)':
draw.cpp:(.text+0x68e): multiple definition of `guard::seek(int, int, float)'
main.o:main.cpp:(.text+0x638): first defined here
draw.o: In function `guard::arrive(int, int, float, float, float)':
draw.cpp:(.text+0x70a): multiple definition of `guard::arrive(int, int, float, float, float)'
main.o:main.cpp:(.text+0x6b4): first defined here
draw.o: In function `agent::normalize_vel()':
draw.cpp:(.text+0x838): multiple definition of `agent::normalize_vel()'
main.o:main.cpp:(.text+0x7e2): first defined here
draw.o: In function `agent::normalize_steer()':
draw.cpp:(.text+0x8b2): multiple definition of `agent::normalize_steer()'
main.o:main.cpp:(.text+0x85c): first defined here
draw.o: In function `guard::wall_avoid(int, int, float)':
draw.cpp:(.text+0x92c): multiple definition of `guard::wall_avoid(int, int, float)'
main.o:main.cpp:(.text+0x8d6): first defined here
draw.o: In function `guard::evade(int, int, float, float, float)':
draw.cpp:(.text+0xa24): multiple definition of `guard::evade(int, int, float, float, float)'
main.o:main.cpp:(.text+0x9ce): first defined here
draw.o: In function `guard::pursue(int, int, float, float, float)':
draw.cpp:(.text+0xb06): multiple definition of `guard::pursue(int, int, float, float, float)'
main.o:main.cpp:(.text+0xab0): first defined here
draw.o: In function `agent::update()':
draw.cpp:(.text+0xbe8): multiple definition of `agent::update()'
main.o:main.cpp:(.text+0xb92): first defined here
draw.o: In function `slashbot::move(dot, hackbot, thing*)':
draw.cpp:(.text+0xcb6): multiple definition of `slashbot::move(dot, hackbot, thing*)'
main.o:main.cpp:(.text+0xc60): first defined here
draw.o: In function `hackbot::move(dot, slashbot, thing*)':
draw.cpp:(.text+0xd8a): multiple definition of `hackbot::move(dot, slashbot, thing*)'
main.o:main.cpp:(.text+0xd34): first defined here
draw.o: In function `dot::player_steer(int)':
draw.cpp:(.text+0xe30): multiple definition of `dot::player_steer(int)'
main.o:main.cpp:(.text+0xdda): first defined here
collision.o: In function `thing::thing()':
collision.cpp:(.text+0x0): multiple definition of `thing::thing()'
main.o:main.cpp:(.text+0x0): first defined here
collision.o: In function `thing::thing()':
collision.cpp:(.text+0x6): multiple definition of `thing::thing()'
main.o:main.cpp:(.text+0x6): first defined here
collision.o: In function `thing::thing(int, int, char)':
collision.cpp:(.text+0xc): multiple definition of `thing::thing(int, int, char)'
main.o:main.cpp:(.text+0xc): first defined here
collision.o: In function `thing::thing(int, int, char)':
collision.cpp:(.text+0x34): multiple definition of `thing::thing(int, int, char)'
main.o:main.cpp:(.text+0x34): first defined here
collision.o: In function `thing::getx()':
collision.cpp:(.text+0x5c): multiple definition of `thing::getx()'
main.o:main.cpp:(.text+0x5c): first defined here
collision.o: In function `thing::gety()':
collision.cpp:(.text+0x66): multiple definition of `thing::gety()'
main.o:main.cpp:(.text+0x66): first defined here
collision.o: In function `thing::get_symbol()':
collision.cpp:(.text+0x72): multiple definition of `thing::get_symbol()'
main.o:main.cpp:(.text+0x72): first defined here
collision.o: In function `agent::agent(int, int, char)':
collision.cpp:(.text+0x80): multiple definition of `agent::agent(int, int, char)'
main.o:main.cpp:(.text+0x80): first defined here
collision.o: In function `agent::agent(int, int, char)':
collision.cpp:(.text+0xd8): multiple definition of `agent::agent(int, int, char)'
main.o:main.cpp:(.text+0xd8): first defined here
collision.o: In function `agent::get_velx()':
collision.cpp:(.text+0x130): multiple definition of `agent::get_velx()'
main.o:main.cpp:(.text+0x130): first defined here
collision.o: In function `agent::get_vely()':
collision.cpp:(.text+0x144): multiple definition of `agent::get_vely()'
main.o:main.cpp:(.text+0x144): first defined here
collision.o: In function `agent::set_alive(bool)':
collision.cpp:(.text+0x158): multiple definition of `agent::set_alive(bool)'
main.o:main.cpp:(.text+0x158): first defined here
collision.o: In function `agent::wall_collide()':
collision.cpp:(.text+0x170): multiple definition of `agent::wall_collide()'
main.o:main.cpp:(.text+0x170): first defined here
collision.o: In function `agent::wall_crash()':
collision.cpp:(.text+0x21c): multiple definition of `agent::wall_crash()'
main.o:main.cpp:(.text+0x21c): first defined here
collision.o: In function `agent::get_alive()':
collision.cpp:(.text+0x25e): multiple definition of `agent::get_alive()'
main.o:main.cpp:(.text+0x25e): first defined here
collision.o: In function `agent::get_prevx()':
collision.cpp:(.text+0x26e): multiple definition of `agent::get_prevx()'
main.o:main.cpp:(.text+0x26e): first defined here
collision.o: In function `agent::get_prevy()':
collision.cpp:(.text+0x2c4): multiple definition of `agent::get_prevy()'
main.o:main.cpp:(.text+0x2c4): first defined here
collision.o: In function `dot::dot(int, int, char)':
collision.cpp:(.text+0x31c): multiple definition of `dot::dot(int, int, char)'
main.o:main.cpp:(.text+0x31c): first defined here
collision.o: In function `dot::dot(int, int, char)':
collision.cpp:(.text+0x358): multiple definition of `dot::dot(int, int, char)'
main.o:main.cpp:(.text+0x358): first defined here
collision.o: In function `guard::guard(int, int, char)':
collision.cpp:(.text+0x394): multiple definition of `guard::guard(int, int, char)'
main.o:main.cpp:(.text+0x394): first defined here
collision.o: In function `guard::guard(int, int, char)':
collision.cpp:(.text+0x3ba): multiple definition of `guard::guard(int, int, char)'
main.o:main.cpp:(.text+0x3ba): first defined here
collision.o: In function `hackbot::hackbot(int, int, char)':
collision.cpp:(.text+0x3e0): multiple definition of `hackbot::hackbot(int, int, char)'
main.o:main.cpp:(.text+0x3e0): first defined here
collision.o: In function `hackbot::hackbot(int, int, char)':
collision.cpp:(.text+0x41c): multiple definition of `hackbot::hackbot(int, int, char)'
main.o:main.cpp:(.text+0x41c): first defined here
collision.o: In function `slashbot::slashbot(int, int, char)':
collision.cpp:(.text+0x458): multiple definition of `slashbot::slashbot(int, int, char)'
main.o:main.cpp:(.text+0x458): first defined here
collision.o: In function `slashbot::slashbot(int, int, char)':
collision.cpp:(.text+0x494): multiple definition of `slashbot::slashbot(int, int, char)'
main.o:main.cpp:(.text+0x494): first defined here
collision.o: In function `guard::get_distance(int, int, int, int)':
collision.cpp:(.text+0x6b0): multiple definition of `guard::get_distance(int, int, int, int)'
main.o:main.cpp:(.text+0x4d0): first defined here
collision.o: In function `guard::normalize_local_steer(float)':
collision.cpp:(.text+0x72a): multiple definition of `guard::normalize_local_steer(float)'
main.o:main.cpp:(.text+0x54a): first defined here
collision.o: In function `guard::flee(int, int, float)':
collision.cpp:(.text+0x7a0): multiple definition of `guard::flee(int, int, float)'
main.o:main.cpp:(.text+0x5c0): first defined here
collision.o: In function `guard::seek(int, int, float)':
collision.cpp:(.text+0x818): multiple definition of `guard::seek(int, int, float)'
main.o:main.cpp:(.text+0x638): first defined here
collision.o: In function `guard::arrive(int, int, float, float, float)':
collision.cpp:(.text+0x894): multiple definition of `guard::arrive(int, int, float, float, float)'
main.o:main.cpp:(.text+0x6b4): first defined here
collision.o: In function `agent::normalize_vel()':
collision.cpp:(.text+0x9c2): multiple definition of `agent::normalize_vel()'
main.o:main.cpp:(.text+0x7e2): first defined here
collision.o: In function `agent::normalize_steer()':
collision.cpp:(.text+0xa3c): multiple definition of `agent::normalize_steer()'
main.o:main.cpp:(.text+0x85c): first defined here
collision.o: In function `guard::wall_avoid(int, int, float)':
collision.cpp:(.text+0xab6): multiple definition of `guard::wall_avoid(int, int, float)'
main.o:main.cpp:(.text+0x8d6): first defined here
collision.o: In function `guard::evade(int, int, float, float, float)':
collision.cpp:(.text+0xbae): multiple definition of `guard::evade(int, int, float, float, float)'
main.o:main.cpp:(.text+0x9ce): first defined here
collision.o: In function `guard::pursue(int, int, float, float, float)':
collision.cpp:(.text+0xc90): multiple definition of `guard::pursue(int, int, float, float, float)'
main.o:main.cpp:(.text+0xab0): first defined here
collision.o: In function `agent::update()':
collision.cpp:(.text+0xd72): multiple definition of `agent::update()'
main.o:main.cpp:(.text+0xb92): first defined here
collision.o: In function `slashbot::move(dot, hackbot, thing*)':
collision.cpp:(.text+0xe40): multiple definition of `slashbot::move(dot, hackbot, thing*)'
main.o:main.cpp:(.text+0xc60): first defined here
collision.o: In function `hackbot::move(dot, slashbot, thing*)':
collision.cpp:(.text+0xf14): multiple definition of `hackbot::move(dot, slashbot, thing*)'
main.o:main.cpp:(.text+0xd34): first defined here
collision.o: In function `dot::player_steer(int)':
collision.cpp:(.text+0xfba): multiple definition of `dot::player_steer(int)'
main.o:main.cpp:(.text+0xdda): first defined here
collect2: ld returned 1 exit status
make: *** [hack_slash] Error 1
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)

Last edited by JMJ_coder; 18th October 2008 at 03:25 PM.
Reply With Quote
 

Tags
make, makefile

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:57 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick