Giter Site home page Giter Site logo

Comments (3)

 avatar commented on May 14, 2024 2

Here's what I've done.

Generate object file

$ clang++ \                       
  -c src/main.cxx \                
  -o 3d-game-shaders-for-beginners.o \
  -std=gnu++11 \                  
  -g \           
  -O2 \    
  -I/Library/Developer/Panda3D/include

Generate binary

$ clang++ \
  3d-game-shaders-for-beginners.o \
  -o 3d-game-shaders-for-beginners \  
  -L/Library/Developer/Panda3D/lib \
  -lp3framework \
  -lpanda \
  -lpandafx \                         
  -lpandaexpress \
  -lpandaphysics \  
  -lp3dtoolconfig \
  -lp3dtool \
  -lpthread

List dylibs linked to binary

$ otool -L 3d-game-shaders-for-beginners
3d-game-shaders-for-beginners:
	@loader_path/../lib/libp3framework.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libpanda.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libpandafx.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libpandaexpress.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libpandaphysics.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libp3dtoolconfig.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	@loader_path/../lib/libp3dtool.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)

As you can see in the output above, all panda-related libraries were marked as a directory above and in a lib dir, which doesn't exist.

We could either copy the dylibs to that directory or fix the paths. I chose to fix them.

Fix linked libraries paths

install_name_tool -change '@loader_path/../lib/libp3framework.1.10.dylib' /Library/Developer/Panda3D/lib/libp3framework.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change '@loader_path/../lib/libpanda.1.10.dylib' /Library/Developer/Panda3D/lib/libpanda.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change '@loader_path/../lib/libpandafx.1.10.dylib' /Library/Developer/Panda3D/lib/libpandafx.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change '@loader_path/../lib/libpandaexpress.1.10.dylib' /Library/Developer/Panda3D/lib/libpandaexpress.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change '@loader_path/../lib/libpandaphysics.1.10.dylib' /Library/Developer/Panda3D/lib/libpandaphysics.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change '@loader_path/../lib/libp3toolconfig.1.10.dylib' /Library/Developer/Panda3D/lib/libp3toolconfig.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change @loader_path/../lib/libp3dtoolconfig.1.10.dylib /Library/Developer/Panda3D/lib/libp3dtoolconfig.1.10.dylib 3d-game-shaders-for-beginners

install_name_tool -change @loader_path/../lib/libp3dtool.1.10.dylib /Library/Developer/Panda3D/lib/libp3dtool.1.10.dylib 3d-game-shaders-for-beginners

Result

$ otool -L 3d-game-shaders-for-beginners
3d-game-shaders-for-beginners:
	/Library/Developer/Panda3D/lib/libp3framework.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libpanda.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libpandafx.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libpandaexpress.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libpandaphysics.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libp3dtoolconfig.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/Library/Developer/Panda3D/lib/libp3dtool.1.10.dylib (compatibility version 1.10.0, current version 1.10.9)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)

from 3d-game-shaders-for-beginners.

ngn999 avatar ngn999 commented on May 14, 2024 2

this is not a compile error, it is a runtime error.
one simple way is to add pand3d to the dyld search path, you can run like this:

DYLD_LIBRARY_PATH=/Library/Developer/Panda3D/lib ./3d-game-shaders-for-beginners

from 3d-game-shaders-for-beginners.

 avatar commented on May 14, 2024

Hey @dandingol03 can you post more details of how you compiled your program (i.e., which commands you used)?

It seems like your binary has the incorrect library path encoded in it, so the loader can't find the panda dylib when you try to run.

Can you try to run the command below to list the libraries linked with your binary?

otool -L 3d-game-shaders-for-beginners

After that, you can use a tool called install_name_tool to fix the path yourself:

install_name_tool -change <path to libp3framework returned by otool> <correct path to libp3framework> 3d-game-shaders-for-beginners

from 3d-game-shaders-for-beginners.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.