[c++] mac os x run problem with hello world code

Hi to all. i installed correctly panda3d.
Following first tutorial i compiled hello world code without error.
But when i run application i have some error and i dont understand why.

this is error :

test(1079) malloc: *** error for object 0xa083f6d8: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
test(1079) malloc: *** error for object 0xa083f6d8: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
test(1079) malloc: *** error for object 0xa083f6d8: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
test(1079) malloc: *** error for object 0xa083f6d8: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
test(1079) malloc: *** error for object 0xa083f6d8: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Attempt to reference unregistered TypeHandle!
Registered TypeHandles are:
Abort trap

Somebody could help me?
thanks…

It appears that something went wrong in the compilation. Perhaps some flags were not set correctly on the compile line?

What OS version are you running, and what kind of CPU do you have? How did you compile the application?

David

thank for your answer.

my operating system is mac os x 10.5.8 and cpu is intel dual core.

in compile time i have no errors but write command that i used :

g++ -c test.cpp -o test.o -fPIC -O2 -I /Python-3.1.2 -I /Developer/Panda3D/include

and after for make execute file:

g++ test.o -o test -fPIC -L/Developer/Panda3D/lib -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct

thank for quick answer :smiley:

Are you compiling against Python 3.1? You have to compile against the same version of Python that Panda is itself compiled against, which is I believe Python 2.6.

I’m a bit surprised if that makes a difference to a standalone C++ application, though, but it’s possible.

David

i compile with python 2.5 but now try to compile with same python of panda 3d :smiley:

i try to compile with python 2.6 and i obtain this error :

In file included from /Developer/Panda3D/include/pta_uchar.h:20,
from /Developer/Panda3D/include/datagram.h:24,
from /Developer/Panda3D/include/netDatagram.h:23,
from /Developer/Panda3D/include/connectionManager.h:20,
from /Developer/Panda3D/include/pStatClientImpl.h:24,
from /Developer/Panda3D/include/pStatClient.h:21,
from /Developer/Panda3D/include/pStatThread.h:20,
from /Developer/Panda3D/include/pStatCollector.h:20,
from /Developer/Panda3D/include/renderState.h:25,
from /Developer/Panda3D/include/pandaNode.h:27,
from /Developer/Panda3D/include/nodePath.h:23,
from /Developer/Panda3D/include/windowFramework.h:19,
from /Developer/Panda3D/include/pandaFramework.h:20,
from test.cpp:1:

have you any idea why?

First of all, Panda3D is compiled against Python 2.5 on OSX Leopard / Snow Leopard.

Also you didn’t show us the full error message.

ok. i tried to compile with python 2.5 and compilation works.
but when i launch application i obtain initial error

Perhaps you could try downloading Panda from source and compiling it directly, using makepanda, instead of using the pre-compiled version? This should resolve any possible incompatibilities from different compiler versions and the like.

David

ok it is a good idea.
:smiley:
i try :smiley:

i try to build panda 3d but i obtain this error :

Generating library cache…
Generating dependencies…
[ 0%] Building C++ object built/tmp/dtoolbase_composite1.o
cc1plus: error: unrecognized command line option “-arch”
cc1plus: error: unrecognized command line option “-arch”
Storing dependency cache.
Elapsed Time: 13 sec

:frowning:

Hm, I think we are narrowing down onto the source of the problem. “-arch” is an Apple extension to gcc. It appears that you have a non-Apple version of gcc installed; and this is almost certainly incompatible with the version of gcc that is installed by default when you install Xcode.

It can probably still be used to compile Panda, but there might be tricky issues that you’ll run into. If you’re a strong C++ programmer, you can probably figure them out and work around them eventually.

But it might be easier just to install the more standard compiler. From whence did you install gcc? Is it possible for you to uninstall it and install Xcode instead?

Or, you could consider doing development in Python instead, which is much more likely to go smoothly, and which a lot of people find easier to develop in than C++.

David

i have xcode installed… and xcode has installed gcc.
:frowning:

Perhaps there is also an additional gcc installed from somewhere else, which is getting called instead of Xcode’s version?

What do you see when you run “gcc --help”? How about if you run the command “touch t.c; gcc -arch i386 t.c”?

David

output of gg --help :

Usage: gcc [options] file…
Options:
-pass-exit-codes Exit with highest error code from a phase
–help Display this information
–target-help Display target specific command line options
–help={target|optimizers|warnings|undocumented|params}[,{[^]joined|[^]separate}]
Display specific types of command line options
(Use ‘-v --help’ to display command line options of sub-processes)
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compiler’s target processor
-print-search-dirs Display the directories in the compiler’s search path
-print-libgcc-file-name Display the name of the compiler’s companion library
-print-file-name= Display the full path to library
-print-prog-name= Display the full path to compiler component
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-print-sysroot Display the target libraries directory
-print-sysroot-headers-suffix Display the sysroot suffix used to find headers
-Wa, Pass comma-separated on to the assembler
-Wp, Pass comma-separated on to the preprocessor
-Wl, Pass comma-separated on to the linker
-Xassembler Pass on to the assembler
-Xpreprocessor Pass on to the preprocessor
-Xlinker Pass on to the linker
-combine Pass multiple source files to compiler at once
-save-temps Do not delete intermediate files
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs= Override built-in specs with the contents of
-std= Assume that the input sources are for
–sysroot= Use as the root directory for headers
and libraries
-B Add to the compiler’s search paths
-b Run gcc for target , if installed
-V Run gcc version number , if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o Place the output into
-x Specify the language of the following input files
Permissible languages include: c c++ assembler none
‘none’ means revert to the default behavior of
guessing the language based on the file’s extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W options must be used.

For bug reporting instructions, please see:
http://gcc.gnu.org/bugs.html.

command touch t.c; gcc -arch i386 t.c give this output :

cc1: error: unrecognized command line option “-arch”

thank you for attention of my problem :slight_smile:

Yep, that’s a non-apple version of gcc, all right. You must have another version of gcc installed. What do you get for “which gcc”? The Xcode version should be in /usr/bin/gcc.

You should edit your PATH so that /usr/bin is first on the path, so that /usr/bin/gcc is found before whatever this other gcc is.

David

ok thanks :smiley:
this is my gcc path /usr/local/bin/gcc.
now i try to change with /usr/bin/ gcc
:smiley:

thannnnnnnnkkks a lot :smiley: i changed path of gcc and all works great! :smiley:
thanks for your important help :smiley:
panda 3d has a good community :smiley:
before start i love this framework :laughing:

thanks. This also solves my problem with cuda.