Compiling C++ example program with Xcode on mac

Hello,

Currently I am attempting to compile an example program using Xcode. Currently my only issue, I assume, is with the files contained in “p3util” I do not know how to link them to my Xcode project. Admittedly, I am a novice, my assumption may be wrong, therefore I will include an error, I have a total of 390 errors all of which consist of failed function calls from files in p3util, or so I believe.

To be clear, p3util is a folder that came with the example programs which contains the source for the coe that functions refer to, namely cBufferViewer.o, in this case.

  "GeomVertexDataPipelineWriter::make_array_writers()", referenced from:
      GeomVertexDataPipelineWriter::check_array_writers() const  in cBufferViewer.o

Sparing a long story, I only have access to this website at random times during the week. I may reply directly, through a friend, or a response will be delayed. I apologize for any inconvenience this may cause.

Where did you get these example programs? We don’t offer official example programs for C++.

I found them on the forums here

[Nooby Question: C++ Code Examples)

I assume they have are in working order, but that may be part of my problem. If I’ve downloaded these and they don’t work right is there any sample programs you could point me to that do work so that I can get my compiler working properly?

I don’t know anything about those samples - you’d have to ask the person who made them.

You could try starting with the “Hello World” sample in the manual. If you can get that to compile, then you’ll be able to compile any Panda program.

Ah thanks. I had forgotten about the Hello world sample, I remember seeing it now. I will try that and see how it goes.

I attempted to compile the hello world sample in xcode but got the following errors:

  "TypedObject::_type_handle", referenced from:
      __ZN11TypedObject12_type_handleE$non_lazy_ptr in helloWorld.o
     (maybe you meant: __ZN11TypedObject12_type_handleE$non_lazy_ptr)
  "PandaFramework::close_framework()", referenced from:
      _main in helloWorld.o
  "TypedObject::~TypedObject()", referenced from:
      Socket_IP::~Socket_IP()in helloWorld.o
      Socket_IP::~Socket_IP()in helloWorld.o
      Socket_IP::~Socket_IP()in helloWorld.o
      Socket_IP::~Socket_IP()in helloWorld.o
  "Notify::assert_failure(char const*, int, char const*)", referenced from:
      BitMask<unsigned int, 32>::set_bit(int)in helloWorld.o
  "PandaFramework::~PandaFramework()", referenced from:
      _main in helloWorld.o
      _main in helloWorld.o
  "TypeRegistry::record_derivation(TypeHandle, TypeHandle)", referenced from:
      register_type(TypeHandle&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, TypeHandle)in helloWorld.o
  "PandaFramework::main_loop()", referenced from:
      _main in helloWorld.o
  "_memory_hook", referenced from:
      _memory_hook$non_lazy_ptr in helloWorld.o
     (maybe you meant: _memory_hook$non_lazy_ptr)
  "TypeRegistry::ptr()", referenced from:
      register_type(TypeHandle&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, TypeHandle)in helloWorld.o
      register_type(TypeHandle&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, TypeHandle)in helloWorld.o
  "PandaFramework::PandaFramework()", referenced from:
      _main in helloWorld.o
  "PandaFramework::open_framework(int&, char**&)", referenced from:
      _main in helloWorld.o
  "PandaFramework::open_window()", referenced from:
      _main in helloWorld.o
  "Notify::ptr()", referenced from:
      BitMask<unsigned int, 32>::set_bit(int)in helloWorld.o
  "Socket_IP::_type_handle", referenced from:
      __ZN9Socket_IP12_type_handleE$non_lazy_ptr in helloWorld.o
     (maybe you meant: __ZN9Socket_IP12_type_handleE$non_lazy_ptr)
  "TypeRegistry::register_type(TypeHandle&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      register_type(TypeHandle&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, TypeHandle)in helloWorld.o
  "TypedObject::init_type()", referenced from:
      Socket_IP::init_type()     in helloWorld.o
  "typeinfo for TypedObject", referenced from:
      typeinfo for Socket_IPin helloWorld.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

This failing, I decided to compile them via command line. It compiled successfully, however, when I ran it and while the grey window did appear,“My Panda3D Window” was missing. The following errors were thrown at launch:

<Error>: kCGErrorIllegalArgument: CGSCopyRegion : Null pointer
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

These kinds of errors usually indicate that you’re not linking in some required libraries, such as libp3dtool.dylib, libp3dtoolutil.dylib, libpanda.dylib, libp3framework.dylib, etc. You’ll have to add these in your XCode project.

I’m not sure why “My Panda3D Window” is missing. As for the error messages, these are normal, harmless, and ignorable.

How might I include these to my xcode project? I added the file path to the lib folder (/Developer/Panda3D/lib) under “library search paths.” I can’t seem to find anywhere that explains to how to add a dylib to an xcode project.

Go to your project properties, select your target and go to the “Summary” tab. You should see “Linked Frameworks and Libraries” there.