"Undefined symbols", but I don't see where/how.

Hi everybody! Sorry if this is a very stupid question or answered to death already.

I have a group of programs that I'm trying to compile then link together to form an executable. I have modified them from their original forms, which I was able to compile make into an executable (they came from a textbook).

Right now, after the modifications, I'm able to compile them successfully with:

mayer:Garcia3d declan$ g++ -Wall -c colider3d.cpp mover3d.cpp randn.cpp rand.cpp sampler3d.cpp sorter3d.cpp dsmc3d.cpp

(where dsmc3d.cpp is the file with main().)

But when I try linking them together to form the executable runme, I get this error:

1
2
3
4
5
6
mayer:Garcia3d declan$ g++ -Wall -o runme colider3d.o sorter3d.o rand.o randn.o sampler3d.o mover3d.o dsmc3d.o 
Undefined symbols:
  "colider3d(Matrix3d&, Matrix3d, double, long&, Matrix3d, double, SortList3d&)", referenced from:
      _main in dsmc3d.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


Before, it was saying the same thing but also with sorter3d(). I noticed that in the sorter3d.cpp file, I had a typo in the name of the function. Fixing that made it stop complaining about not finding the symbol "sorter3d()". So I looked everywhere in the file with main() and colider3d.cpp and I can't find a typo, so I'm beginning to suspect it's something else. I've googled this error but didn't find anything of use.

Here is the code for the file with main() and the file colider3d.cpp. Please excuse my atrocious indentation style and other things:

colider.cpp: http://pastebin.com/87UVJVVd
dsmc3d.cpp: http://pastebin.com/Pn090Txu

I suspected that maybe I had the arguments wrong, so it thought it was a different function. But that's not the case. colider() is only mentioned twice in dsmc3d.cpp, once in the function prototype, and once when it is called. I don't see anything wrong with either of them.

Can anyone help me? Thanks!

EDIT: Well, I'm an idiot! I swear I checked the arguments and parameters 100 times, but I missed an ampersand after Matrix3d, twice. Works now.

Thanks!
Last edited on
You have more typos.

The arguments in Line 10 of this file http://pastebin.com/Pn090Txu are not the same as line 7 from this file http://pastebin.com/87UVJVVd.
Last edited on
Topic archived. No new replies allowed.