Archived

This topic is now archived and is closed to further replies.

This topic is 5593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have three source files. main.cpp, globals.cpp and O_Bullet.cpp. My header files are Gloabls.h and O_Bullet.h. Bullet is a class with the header in O_Bullet.h and the funcitons in O_Bullet.cpp. Within Globals.h I declare:
extern Bullet bullets[];
Within Globals.cpp:
Bullet bullets[10];
and finally in Main.cpp I include globals.h and create the actual instances of the Bullets.
for(int t = 0; t < 10; t++)
bullets[t] = Bullet::Bullet(240,160,270,200.0f,1.0f);

I get the follwing link error: globals.o: In function '__static_initialization_and)destruction_0(int, int):globals.o(.text+0x50c): undefined reference to '__gxx_personality_sj0' collect2: ld returned 1 exit status I'm thinking that perhaps I get this error because I've got an array of 'Bullet'. I also have a similar class 'Ship' and an instance declared and created in the exact same way except there is no array and that works fine. Can someone help me here? Thanks in advance slip [edited by - slip on January 30, 2003 11:45:59 PM]

Share on other sites
hmm I don''t want to demand help... but some would be nice... I''m not sure this thread got lost down the list because I edited a few time... but yeah... Does anyone know whats going on there?

slip

Share on other sites
Try compliling with g++/c++ instead of gcc.

Share on other sites
Cool... it compiles alright... but I''m not sure my code is working right, I''ll see.
Thanks

slip

Share on other sites
Right... I''ve run into another problem, though now its not a linker or compile problem. My Ship class has a variable xvel and one yvel which are both float. If I compile the code with

Bullet bullets[10];

in globals.cpp for some reason these don''t change when I press left or right. The Bullet class has varables named xvel and yvel also. They are all public, even in my Ship class. I don''t understand why declaring Bullet bullets[10]; would affect my program so much.

Does anyone have any ideas?

slip

Share on other sites
Yes, more info, show some code, explain why pressing left doesn''t have the effect you expect. Possibly start a new thread as this is now a different topic to the original.

Although, saying all that usually I find that once one problem is dealt with another immediately raises its ugly head. It''s tempting to immediately go and say to the last person who helped ''I''ve got another problem now'' without spending a lot of time thinking about it or really trying to establish the cause of the trouble.

Look at it a bit longer to get to the root. Write out an explanation of how you think it should be working and why the code you''ve written represents that design. You''ll (hopefully) find somewhere that it doesn''t match up. Even if you don''t understand how to make it match you''ll have narrowed it down and will be in a better position to explain it to us.

Peace

Share on other sites
To little detail here. But one guess is that you are changing your variables inside a function

MakeMovement(x, y);

MakeMovement(float x, float y)
{
//Do something
}

This code only alters the local variables you need to use pointers to affect the variables you send in.

Wild guess....

• 40
• 15
• 10
• 23
• 19