所以我尝试为 linux 移植一些 Boost.Extension 示例。
该示例在此处进行了描述。这是我的代码移植(带有动物的类、动物原型、主应用程序、一般所有移植的想法都在这里描述,以及一些当前的 linux 进展在这里(一些示例确实可以根据需要工作!))。当我在它编译的 linux 下编译这个示例时,它会找到带有动物的库,但输出:
Animals not found!
这只会发生if(factories.empty())
。
我尝试将扩展示例移植到跨平台基础上 - 所以我在 Windows 下尝试了相同的代码 - 就像一个魅力!查找所有动物和输出:
Creating an animal using factory:
Cougar factory Created an animal:
cougar Age: 2 Creating an animal using
factory: Leopard factory Created an
animal: leopard Age: 3 Creating an
animal using factory: Puma factory
Created an animal: puma Age: 4
Creating an animal using factory:
Wildcat factory Created an animal:
wildcat Age: 5
那么......为什么它在具有相同代码的linux上表现如此?为什么它在 Windows 下运行得这么好?
更新:
那么如何使用 premake 构建这些东西:
- 你从这里得到svn(只需要这个文件夹)
- 您可以为您的平台获取 premake 或从源代码构建它并将其放入您从 svn 下载的文件夹中
- 您应该已经编译并安装了官方的 Boost(请阅读我们在目录中提供的 ReadMe.txt 文件),所以需要什么:
- Boost C++ 库 (我们测试了 1.4.16 版)
- Boost-Extension(我们使用最新版本,我们将其作为 boost 'boost/extension/
**
' 的一部分进行处理,我们必须制作一些 chandes(实际上只有一个)来提升扩展,所以我们在Boost.Extension.Tutorial/libs/boost/extension/
文件夹中提供它,所以当你下载 svn 时你得到了它,它只是标题) - Boost-Reflection(我们使用它是因为本教程,我们使用最新版本,我们将它作为 boost 'boost/reflection/
**
' 的一部分来处理 *为了简单起见,我们建议将其放入Boost.Extension.Tutorial/libs/boost/reflection
*)
- 现在,当官方 Boost 在您的系统中时,文件夹中只有头文件 Boost-reflection 和 Boost-extension
Boost.Extension.Tutorial/libs/boost
,premake4 可执行文件在Boost.Extension.Tutorial/
文件夹中,我们可以简单地调用Boost.Extension.Tutorial/ premake4-build-windows.bat
windows 来获取 Visual Studio 的 sln 或Boost.Extension.Tutorial/ premake-build.sh
获取 makefile。 - 您可以在生成的项目文件夹中找到生成的解决方案/makefile。
- 祝你好运!=)
更新 2:
Windows 和 Linux 的项目文件现在在 svn 中,因此您可以使用 premake 进行项目创建 - 只有 Boost、我们的 svn 和反射头文件 lib。