Panda3d编译

本文档详细介绍了如何编译Panda3D,包括从获取依赖到执行编译步骤。在编译过程中,可能会遇到如'Error in ffmpegVirtualFile.cxx'和'size_t'语法错误的问题,通过将'int64_t'替换为'__int64',以及在openCVTexture.h中添加缺失的类型定义,可以成功解决这些问题。对于不需要Python支持的用户,可以使用 '--no-python' 参数进行编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在官网上,先有这么一段


Note that in the past, it was very difficult to build Panda3D. Things have improved. It is now fairly straightforward to download and compile panda. In particular, this is a sensible thing to do if you wish to add some functionality to panda.

To avoid possible consistency problems, the documentation for building the source is included with the source, not in the manual. Download a source package from the panda website, then look in the directory "doc," where you will find two files: INSTALL-MK and INSTALL-PP. These contain the instructions on the two different build-systems, "makepanda" and "ppremake".


While building you'll get a list of not found dependencies. Further descriptions of those can be found here: Dependencies.


这里面提供的信息是:

在源代码的根目录的doc下,有两个文件,分别是INSTALL-MK 和 INSTALL-PP。这两个文件提供了具体编译Panda3D的步骤。


特别要注意的是,在编译前,下面的链接是Panda3d的依赖表:

https://www.panda3d.org/manual/index.php/Dependencies


另外,官网上有一篇教程,说到编译这件事情:

https://www.panda3d.org/manual/index.php/Tutorial:_Compiling_the_Panda3D_Source_on_Windows


实际上,我的编译步骤(Python、VS2008、DX都装好):

1、CMD下进入源代码根目录

2、makepanda\makepanda.bata --everything


就可以看到编译了(有相关的进入可以看到)。

@ 第一次失败,出错信息:  Error in ffmpegVirtualFile.cxx near line 41, column 36 

修正方式:定位到ffmpegVirtualFile.cxx,替换所有的int64_t到__int64就可以。


然后整个就可以编译过了。


如果不需要python,那么可以用 --no-python参数。

@ 会失败,出错信息:[ 35%] Building C++ object built/tmp/vision_composite1.obj vision_composite1.cxx d:\panda3d-1.7.2_no_python\panda\src\vision\openCVTexture.h(89) : error C2061: syntax error : identifier 'ssize_t' 

修正方式:定位到openCVTexture.h,在#ifdef HAVE_OPENCV下面,加入

#ifndef HAVE_SSIZE_T 
#ifdef MS_WIN64 
typedef __int64 ssize_t; 
#else 
typedef _W64 int ssize_t; 
#endif 
#define HAVE_SSIZE_T 1 
#endif 

然后整个没有python的就编译成功了。



Panda3D是一个开源的3D游戏引擎,支持Python和C++编程语言。安装Panda3D可以通过多种方式完成,以下是几种常见的方法: ### 方法一:使用pip安装 这是最简单的方法,适用于大多数Python环境。 1. 打开命令行或终端。 2. 输入以下命令并按回车: ```bash pip install panda3d ``` ### 方法二:使用conda安装 如果你使用Anaconda或Miniconda,可以使用conda来安装Panda3D。 1. 打开Anaconda Prompt或终端。 2. 输入以下命令并按回车: ```bash conda install -c conda-forge panda3d ``` ### 方法三:从源代码编译 如果你需要最新的开发版本或特定的功能,可以从源代码编译Panda3D。 1. 下载Panda3D源代码: ```bash git clone https://github.com/panda3d/panda3d.git ``` 2. 进入源代码目录: ```bash cd panda3d ``` 3. 创建并激活一个虚拟环境(可选,但推荐): ```bash python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows ``` 4. 安装必要的依赖: ```bash pip install -r requirements.txt ``` 5. 编译Panda3D: ```bash python setup.py install ``` ### 方法四:使用预编译的二进制文件 Panda3D提供了预编译的二进制文件,可以直接从官方网站下载并安装。 1. 访问Panda3D官方网站:[https://www.panda3d.org/](https://www.panda3d.org/) 2. 导航到下载页面。 3. 下载适合你的操作系统的预编译版本。 4. 按照下载的安装程序进行安装。 ### 验证安装 安装完成后,可以通过以下命令验证安装是否成功: ```python import panda3d print(panda3d.__version__) ``` 如果在运行上述代码时没有报错,并且输出了Panda3D的版本号,说明安装成功。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值