build error on OS X

I’ve been trying to build Panda3D all day, but I keep getting the same error regardless of how I set up the build environment.

dyld: Library not loaded: libpystub.dylib
  Referenced from: /usr/local/panda/bin/interrogate
  Reason: image not found
make[1]: *** [Opt3-OSX/libexpress_igate.cxx] Trace/BPT trap
make: *** [express] Error 2

Any ideas?

run “otool -L /usr/local/panda/bin/interrogate” and check if libstub.dylib has a path assigned.

mine looks like this:

/usr/local/panda/bin/interrogate:
	libpystub.dylib (compatibility version 0.0.0, current version 0.0.0)
	libinterrogatedb.dylib (compatibility version 0.0.0, current version 0.0.0)
	libdconfig.dylib (compatibility version 0.0.0, current version 0.0.0)
	libdtoolutil.dylib (compatibility version 0.0.0, current version 0.0.0)
	libdtoolbase.dylib (compatibility version 0.0.0, current version 0.0.0)
	libprc.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libssl.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
	/usr/lib/libcrypto.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

if the path is wrong you can change it with:

install_name_tool /wrong/path/to/libpystub.dylib libpystub.dylib /usr/local/panda/bin/interrogate

I get exactly the same output from otool, but I did figured out what’s going on. I can run interrogate from the command line by itself just fine. However when I was running ppremake and make I was getting permission errors. Instead of fixing the permissions, I took the lazy approach and just ran make with sudo. This was wrong. When interrogate is run from sudo it can’t find the library.

Here is the output from interrogate:

$ interrogate

Usage:
  interrogate [opts] file.C [file.C ...]
  interrogate -h

And here is the output from interrogate with sudo:

$ sudo interrogate
Password:
dyld: Library not loaded: libpystub.dylib
  Referenced from: /usr/local/panda/bin/interrogate
  Reason: image not found
Trace/BPT trap

if you run it as sudo, the environment-variables might change. run “sudo bash” and check the environment “export”.

Or just change the ownership of interrogate:
chown yourusername:yourusername /usr/local/panda/bin/interrogate
or for the whole directory:
chown -R yourusername:yourusername /usr/local/panda/*

Yeah my environment variables are set inside .bash_login and that’s not read when sudo is invoked.

I have a new problem with interrogate now. Here’s the error I’m getting:

      *** Error in /usr/include/ctype.h near line 146, column 10:
      syntax error, unexpected KW_UNSIGNED, expecting '{' or ';' or ':' or '='
Error parsing file: 'downloader_composite2.cxx'
make[1]: *** [Opt3-OSX/libdownloader_igate.cxx] Error 1
make: *** [downloader] Error 2

I changed the Makefile to use /Developer/SDKs/MacOSX10.4u.sdk/usr/include so that it would read ctype.h from the SDK, but I still get a similar error.

      *** Error in /Developer/SDKs/MacOSX10.4u.sdk/usr/include/ctype.h near line 117, column 5:
      syntax error, unexpected KW_INT, expecting '{' or ';' or ':' or '='
Error parsing file: 'downloader_composite2.cxx'
make: *** [Opt3-OSX/libdownloader_igate.cxx] Error 1

The line before each error in ctype.h is __BEGIN_DECLS otherwise they are different. I think interrogate doesn’t know how to deal with __BEGIN_DECLS.

do you use ppremake or the modified makepanda? ppremake should work (with some possible problems), while the modified makepanda is still in the works.

I’m using ppremake right now.

#define OPTIMIZE 3

#define UNIVERSAL_BINARIES 1

#define PYTHON_IPATH /usr/include/python2.5
//#define PYTHON_LPATH /usr/lib/python2.5

//#define INSTALL_LIB_DIR /Library/Python/2.5/site-packages

#define JPEG_IPATH /opt/local/include
#define JPEG_LPATH /opt/local/lib

#define PNG_IPATH /usr/X11/include/libpng
#define PNG_LPATH /usr/X11/lib/

#define TIFF_IPATH /opt/local/include
#define TIFF_LPATH /opt/local/lib

//#define TAR_IPATH /opt/local/include
//#define TAR_LPATH /opt/local/lib

#define FFTW_IPATH /opt/local/include
#define FFTW_LPATH /opt/local/lib

// Berkeley DB isn't used anymore.

#define CGGL_LIBS
#define CGGL_FRAMEWORK Cg
#define HAVE_CGGL 1

#define CG_LIBS
#define CG_FRAMEWORK Cg
#define HAVE_CG 1

#define CG_IPATH /Library/Frameworks/Cg.framework/Headers
#define CG_LPATH /Library/Frameworks/Cg.framework

// No VRPN cause most of us don't own VR helmets.
// Helix is for streaming media. Don't need that.

#define ZLIB_IPATH /usr/include/
#define ZLIB_LPATH /usr/lib

// Miles Sound System is proprietary, so no dice.
// Why use FMOD when we have OpenAL.
// Don't need gtk
// Don't need OpenCV cause my computer doesn't need vision.

#define OPENAL_LIBS
#define OPENAL_IPATH /System/Library/Frameworks/OpenAl.framework/Headers
#define OPENAL_LPATH /System/Library/Frameworks/OpenAl.framework
#define OPENAL_FRAMEWORK OpenAl
#define HAVE_OPENAL 1
#define HAVE_AUDIO 1

#define FFMPEG_IPATH /opt/local/include/ffmpeg
#define FFMPEG_LPATH /opt/local/lib

#define ODE_IPATH /opt/local/include
#define ODE_LPATH /opt/local/lib

// Don't have Maya...I use free tools.

#define HAVE_THREADS 1

#define SIMPLE_THREADS 1

Can you post you Config.pp?

Sorry missed that on the first view…

That’s because i thought you woudnt response so fast and thought i could modify the post :slight_smile:

Can you try compiling without:

#define OPTIMIZE 3
#define UNIVERSAL_BINARIES 1
#define SIMPLE_THREADS 1

be aware that compiling with ffmpeg only works (and is compiled) if you incorporate the patches i made. However for the 1.5.0 build i only used a part of them. OpenAL build is currently useless, as it’s not useful right now (only 1 sound-channel running, crashes often if used with more then 1 sound).

Patches for panda3d (ffmpeg & openal):
discourse.panda3d.org/viewtopic.php?t=3402

My Config.pp

#define GENPYCODE_LIBS libpandaexpress libpanda libpandaphysics libdirect libpandafx libpandaegg

#define PRC_PATH_ENVVARS CFG_PATH ETC_PATH 
#define DEFAULT_PATHSEP : :

// should help py2app 'relinking?' the libs
#define LFLAGS -headerpad_max_install_names

// since leopard we must link against /Developer
#define LOCAL_INCS /Developer/SDKs/MacOSX10.4u.sdk/usr/include
#define LOCAL_LIBS /Developer/SDKs/MacOSX10.4u.sdk/usr/lib

#define HAVE_PYTHON 1
#define PYTHON_IPATH /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/
#define PYTHON_LPATH /Library/Frameworks/Python.framework/Versions/2.4/lib/
#define INSTALL_PYTHON_SOURCE 1

#define ZLIB_IPATH /opt/local/include 
#define ZLIB_LPATH /opt/local/lib 

#define JPEG_IPATH /opt/local/include 
#define JPEG_LPATH /opt/local/lib 

#define PNG_IPATH /opt/local/include 
#define PNG_LPATH /opt/local/lib 

// WITH TAR ENABLED PRODUCES THIS ERROR (using sdk10.4):
// in ./src/express
//   *** Error in patchfile.h near line 133, column 33:
//   syntax error, unexpected IDENTIFIER, expecting '{' or ';' or ':' or '='
// Error parsing file: 'patchfile.h'
// make[1]: *** [Opt3-OSX/libexpress_igate.cxx] Error 1
// make: *** [express] Error 2
// #define TAR_IPATH /opt/local/include 
// #define TAR_LPATH /opt/local/lib
// probably size_t is not defined...

#define TIFF_IPATH /opt/local/include 
#define TIFF_LPATH /opt/local/lib 

#define HAVE_ODE 1
#define ODE_IPATH /opt/local/include/ode
#define ODE_LPATH /opt/local/lib

#define ZLIB_IPATH /opt/local/include
#define ZLIB_LPATH /opt/local/lib

#define FFMPEG_IPATH /opt/local/include/ffmpeg
#define FFMPEG_LPATH /opt/local/lib

#define HAVE_FREETYPE 1
//#define FREETYPE_IPATH /opt/local/include/freetype2
//#define FREETYPE_LPATH /opt/local/lib
// osx has freetype included in developer
#define FREETYPE_IPATH /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/include/freetype2
#define FREETYPE_LPATH /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib

#define HAVE_FMODEX 1
#define FMODEX_IPATH /Volumes/SQP/_DOWNLOADS/_DEVELOPMENT/_LIBRARYS/fmod-dev-4.09.09/api/inc
#define FMODEX_LPATH /Volumes/SQP/_DOWNLOADS/_DEVELOPMENT/_LIBRARYS/fmod-dev-4.09.09/api/lib

// prevent -lcg
#define CGGL_LIBS
#define CGGL_FRAMEWORK Cg
#define HAVE_CGGL 1

// prevent -lcg
#define CG_LIBS
// this is wrong, includes -framework cg in src/text, which causes error
//#define CG_FRAMEWORK Cg
#define HAVE_CG 1

// prevent -lopenal
#define OPENAL_LIBS
#define OPENAL_IPATH /Library/Frameworks/OpenAl.framework/Headers
#define OPENAL_LPATH /Library/Frameworks/OpenAl.framework
#define OPENAL_FRAMEWORK OpenAl
#define HAVE_OPENAL 1
#define HAVE_AUDIO 1

#define GL_FRAMEWORK OpenGL
// without this glgsg fails on include
#define GL_IPATH /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/OpenGL.framework/Versions/A/headers
#define GL_LPATH /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/OpenGL.framework
// or is it /Library/Frameworks/OpenGL.framework/Versions/Current/Libraries/libGL ? (the current setting seems to work)
#define HAVE_GL 1

#define HAVE_THREADS 1
#define USE_MEMORY_MALLOC 1

// // additional notes: (this should actually not be used anymore, but im not really sure)
// // i added /System/Library/Frameworks/IOKit.framework/Versions/A/Headers
// typedef uint64_t		io_user_reference_t;
// // before:
// enum {
//     kOSAsyncRef64Count	= 8,
//     kOSAsyncRef64Size 	= kOSAsyncRef64Count * sizeof(io_user_reference_t)
// };
// typedef io_user_reference_t OSAsyncReference64[kOSAsyncRef64Count];
// // i could not find a different solution, how this works in the end

Compiling without:

#define OPTIMIZE 3
#define UNIVERSAL_BINARIES 1
#define SIMPLE_THREADS 1

Didn’t help…

The downloader depends on OpenSSL and zlib so I added:

#define HAVE_OPENSSL
#define HAVE_ZLIB

And commented out:

//#define ZLIB_IPATH /usr/include/
//#define ZLIB_LPATH /usr/lib

And now it’s compiling just fine, perhaps Panda3D can’t be compiled with the system’s default OpenSSL or zlib. I see that you are using zlib from MacPorts, I’m guessing you’re also using OpenSSL from MacPorts.

After this build finishes, I’ll try building again to see if I can isolate the issue.

afaik you should not link/include anything under /usr/lib \ /usr/include, it may work on your own system, but will fail very likely if moved to another system. Use /Developer/SDKs/MacOSX10.4u.sdk/… or macport (/opt/local/) instead. On 10.5 building against /usr/lib will fail, under 10.4 it worked, but i dont recommend it.

Well I isolated the issue. I can’t use the system default zlib, but I can use Leopards version of OpenSSL.

I prefer the default OpenSLL because the MacPorts version breaks ssh. :frowning:

I was having the same problem with interrogate not finding those libraries when I ran sudo make (and getting permission errors when I just ran make). I just figured out how to fix it, so in case anyone else has this problem it might help.

I did sudo bash then tried “export $DYLD_LIBRARY_PATH”. Since it was running root and not my username, that variable was empty. I ran the export that was in my .bash_profile (still under root) then ran make, and everything worked fine. Hope that helps someone!