Compiling simple C++ code

Trying to compile and run the simple first example in the online manual on a Mac OS X (Snow Leopard).

I get the following output when I build:

Linked console executable: bin/debug/pandtemp
Undefined symbols:
“TypedObject::_type_handle”, referenced from:
TypedObject::get_class_type() in main.o
“PandaFramework::close_framework()”, referenced from:
_main in main.o
“TypedObject::~TypedObject()”, referenced from:
Socket_IP::~Socket_IP() in main.o
Socket_IP::~Socket_IP() in main.o
Socket_IP::~Socket_IP() in main.o
Socket_IP::~Socket_IP() in main.o
"Notify::assert_failure(char const*, int, char const*): referenced from:
BitMask<unsigned int, 32>::set_bit(int)in main.o

etc etc (I had to type that…how do I simply copy and paste all the output?)

at the end I get

ld: symbol(s) not found
collect2: ld returned 1 exit status

Can’t seem to run the example.

Any help would be appreciated?

Thanks

It seems like you forgot to link to one or more of Panda3D’s libraries. Which libraries did you link to? How did you compile it?

No quite sure (I don’t use Mac) but I believe it could have to do with the fact that you dont really have a “debug” version (if you don’t build one yourself) of Panda3D coming with the SDK.

Did you try build that in “release” mode ?

[EDIT]
ups didn’t see rdb had already answered :slight_smile:
[/EDIT]

I have included:
panda3d/includes
panda3d/lib
and the python header files of python2.5

I am not exactly sure what this means but I typed the following command

touch t.c; gcc -arch i386 t.c

it gives this:

Undefined symbols:
“_main”, referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Thanks for any help.

I just try to build while working in Code Blocks. Still learning about different settings so I might have some wrong settings…using default values at this point.

These commands:

touch t.c
gcc -arch i386 t.c

First you create an empty t.c file, and then you try to compile it. But the linker errors because you don’t have a main function - of course, because it’s empty.

But I don’t see how this is related to anything. You just need to set the appropriate linker definitions, so that your compiler links against the Panda3D libraries.

I finally got the linker settings correct…I think. I was putting the search folders in the compiler section that needed to be put in the linker settings.

Now I only get warnings related to 64 bit architecture…

warning: option -s is obsolete and being ignored
warning: in /Developer/Panda/lib/libp3framework.dylib, missing required architecture x86_64 in file

and several more of the exact same warning but related to different dylib files.

Not sure exactly how to address this…

Any ideas?

Thanks again.

You should only compile for i386, not for x86_64.

Ok… I added the flag -march=i386 so here are the full compiler and linker options for code blocks

<Compiler>
		<Add option="-march=i386" />
		<Add option="-O2" />
		<Add option="-O" />
		<Add option="-Wall" />
		<Add option="-fexceptions" />
		<Add option="-fPIC" />
		<Add directory="/Developer/Panda3D/include" />
		<Add directory="/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5" />
	</Compiler>
	<Linker>
		<Add option="-fPIC" />
		<Add option="-lp3framework" />
		<Add option="-lpanda" />
		<Add option="-lpandafx" />
		<Add option="-lpandaexpress" />
		<Add option="-lp3dtoolconfig" />
		<Add option="-lp3dtool" />
		<Add option="-lp3pystub" />
		<Add option="-lp3direct" />
		<Add directory="/Developer/Panda3D/lib" />

I get the following error. Maybe it is a code blocks error?

error: CPU you selected does not support x86-64 instruction set.

I though that specifying -march=-i386 would preclude this error.

hmmmm

Thanks for any thoughts

That’d be “-arch i386”. If that’s not it, Code::Blocks may be adding flags itself. Maybe it’s some kind of ‘universal binaries’ option?

That seems like it must be it although I can’t seem to find any settings specified in the settings pull down menu that I think is the global settings.

I tried to switch to XCode to see if I could get it to compile there.

Put in the same settings and get the following error:

Directory ‘/Development/panda3d/lib’ following the -L not found
Library not found for -lp3direct

hmmmm…

The only path I have for the libaries is:
/Develpment/panda3d/lib

am I missing one??
that is the only lib folder I have listed in code blocks.

Macs are pretty difficult :slight_smile: perhaps I should go back to PC

Thanks for any suggestions.

I think it’s /Developer, not /Development or /Develpment.

Thanks for all the feedback.

It works and now I can start to see if I can code something useful :slight_smile: