Boost-Extension-Reflection 不使用 bjam 编译官方示例时如何修复分段错误错误?

发布于 2024-11-04 01:47:05 字数 4844 浏览 0 评论 0 原文

所以我尝试为标准 IDE 移植一些 Boost.Extension 示例 - 使其不受 BJAM 的影响,并能够跨平台以标准方式使用它们

我现在遇到问题的示例在此处进行了描述。这是我的代码端口(我们尝试在主代码文件中加载的库主应用程序,常规这里描述了所有端口想法,以及一些当前的 Linux 进展在这里(大多数示例确实可以根据需要工作!))。当我在 Linux 下编译此示例时,它会编译,它会找到库,但在执行期间失败,并出现 分段错误错误 。当我在 Windows 上编译它时,会发生同样的事情。

我已尽力不更改原始教程代码 尽可能多。

那么代码出了什么问题,为什么会失败,唯一重要的是 - 如何修复它?

那么如何使用 premake 构建这些东西:

  1. 你会得到svn 从这里(仅此文件夹是必需的)
  2. 得到为您的平台进行 premake 或从源代码构建它并将其放入您从 svn 下载的文件夹中
  3. 您应该编译并安装官方 Boost(请阅读我们在目录中提供的 ReadMe.txt 文件),所以需要什么:
    • Boost C++ 库(我们使用版本 1.4.16 进行测试)
    • Boost-Extension(我们使用最新版本,我们将其作为 boost 'boost/extension/ 的一部分**' 我们必须制作一些chandes(实际上只有一个)来增强扩展,因此我们将其提供在Boost.Extension.Tutorial/libs/boost/extension/文件夹中,以便当你下载 svn 时你就得到了它,它只是标题
    • Boost-Reflection(我们使用它因为本教程< /a> ,我们使用 最新版本 ,我们将其作为一部分boost 'boost/reflection/**' *为了简单起见,我们建议将其放入 Boost.Extension.Tutorial/libs/boost/reflection * )
  4. 现在,当您的系统中有官方 Boost 时,只有 Boost-reflection 和 Boost-extension 头文件位于 Boost.Extension.Tutorial/libs/boost 文件夹中,premake4 可执行文件位于 < code>Boost.Extension.Tutorial/ 文件夹中,我们可以简单地在 Windows 上调用 Boost.Extension.Tutorial/ premake4-build-windows.bat 来获取 Visual Studio 或 Boost 的 sln .Extension.Tutorial/ premake-build.sh 获取 makefile。
  5. 您可以在生成的项目文件夹中找到生成的解决方案/makefile。
  6. 祝你好运!=)

更新:

项目文件 适用于 Windows 和 Linux 的版本现在位于 svn 中,因此您可以使用 premake 来创建项目 - 只需拥有 Boost、我们的 svn 和反射标头专用库即可。

更新 2: 一般来说,我的电脑在 Windows 和 Linux 上都会出现问题。有关我的 Linux 的详细信息(这是一个包含 Mono 2.10.2 的 openSUSE 11.3 VMWare 映像< /a>) GCC (gcc -v):

rupert@linux:~> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.5/lto-wrapper
Target: i586-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system-libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux
Thread model: posix
gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux) 

我的 Windows 是标准 Windows 7,带有 Visual Studio Team System 2008 Team Suite。

我的 boost 是 1.46.1 从这里下载手动编译和安装。

So I try to port some Boost.Extension samples for standart IDEs - to make tham free from BJAM and to be able to work with them in standard ways across platforms.

The sample I have trobules with now is described here. Here is my code port (library we try to load in main code file, main application, general all port idea is described here, and some current linux progress here (most of the samples really work as needed!)). When I compile this sample under linux it compiles, it finds library but fails during execution with segmentation fault error. When I compile it on Windows same stuff happens.

I have tried my best not to change original tutorial code as much as possible.

So what is wrong with code, why if fails, and only thing that matters - how to fix it?

So how to build this stuff with premake:

  1. You get svn from here (only this folder is required)
  2. You get premake for your platform or build it from source and put it into folder you downloaded from svn
  3. You should have official Boost compiled and installed (please read ReadMe.txt file we provide in directory) so what is needed:
    • Boost C++ library's (we tested with version 1.4.16)
    • Boost-Extension ( we use latest revision , we adress it as part of boost 'boost/extension/**' We had to make some chandes (actually only one) to boost extension so we provide it inside Boost.Extension.Tutorial/libs/boost/extension/ folder so when you downloaded svn you got it, it is header only )
    • Boost-Reflection ( we use it because of this tutorial , we use latest revision , we adress it as part of boost 'boost/reflection/**' *and for simplness we recommend just to put it into Boost.Extension.Tutorial/libs/boost/reflection * )
  4. Now when official Boost is in your system, header only Boost-reflection and Boost-extension are in Boost.Extension.Tutorial/libs/boost folder, premake4 executable is inside Boost.Extension.Tutorial/ folder we can simply call Boost.Extension.Tutorial/ premake4-build-windows.bat on windows to get sln for Visual Studio or Boost.Extension.Tutorial/ premake-build.sh to get makefiles.
  5. You can find generated solution/makefiles inside generated projects folder.
  6. Have good luck!=)

Update:

Project files for Windows and Linux are now in svn so you can get aroung project creation with premake - just have Boost, our svn, and reflection headers only lib.

Update 2:
So generally my computer shows problems both on Windows and Linux. Details on my Linux (which is an openSUSE 11.3 VMWare image which includes Mono 2.10.2) GCC (gcc -v):

rupert@linux:~> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.5/lto-wrapper
Target: i586-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system-libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux
Thread model: posix
gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux) 

My windows is standard Windows 7 with Visual Studio Team System 2008 Team Suite on board.

My boost is 1.46.1 download from here compiled and installed manually.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌若浮生 2024-11-11 01:47:06

配置一定有区别,因为这是我测试的结果:

  1. cd /tmp
  2. svn checkout http://cloudobserver.googlecode.com/svn/branches/v0.4/ cloudobserver
  3. cd cloudobserver/Boost.Extension.Tutorial/libs/boost/
  4. svn co <​​a href="http://svn.boost.org/svn/boost/sandbox/boost/reflection/" rel="nofollow">http://svn.boost.org/svn/boost/sandbox/ boost/reflection/
  5. cd ../../projects/linux-gmake/
  6. make
  7. cd bin/debug/
  8. export LD_LIBRARY_PATH=.
  9. ./

互操作性输出:

第一印象:这是一辆SUV。
第二个反思:它是一个紧凑型。

也许是一个发行版?

  1. cd ../..
  2. make -Bs config=release
  3. cd bin/release/
  4. ./

互操作性

第一印象:这是一辆SUV。
第二个反思:它是一个紧凑型。


更新

我已经在 32 位 Linux 上使用

  • ubuntu gcc 4.4.5、boost 1.42.0
  • ubuntu gcc 4.5.1、boost 1.42.0
  • debian gcc 4.5.2-8、boost 1.46.1.1
  • debian gcc 4.6.1 20110428(预发布) 进行了测试), 升压

1.46.1.1 Mono-2.10.2.vmdk 映像 SuSE 与

  • gcc 4.5.0 20100604、boost 1.42.0.7.1.1(来自 yast2 存储库)
  • gcc 4.5.0 20100604、boost 1.46.1(来自源代码)

结论、提示

所有测试的版本都给了我正确的结果和相同的输出。 PEBCAK 肯定发生了什么事情吗? 也许可以在新的虚拟机上重复我的上述步骤来亲自查看

我真正看到的唯一错误是

  • 错误的库路径(动态加载(旧的?)不兼容的 so 版本)
  • 使用了错误的标头(导致 so 的不兼容版本)

There must be difference in configuration, because this is the result of my testing:

  1. cd /tmp
  2. svn checkout http://cloudobserver.googlecode.com/svn/branches/v0.4/ cloudobserver
  3. cd cloudobserver/Boost.Extension.Tutorial/libs/boost/
  4. svn co http://svn.boost.org/svn/boost/sandbox/boost/reflection/
  5. cd ../../projects/linux-gmake/
  6. make
  7. cd bin/debug/
  8. export LD_LIBRARY_PATH=.
  9. ./Interoperability

outputs:

First reflection: It's an SUV.
Second reflection: It's a compact.

A release buld perhaps?

  1. cd ../..
  2. make -Bs config=release
  3. cd bin/release/
  4. ./Interoperability

First reflection: It's an SUV.
Second reflection: It's a compact.


Update

I have since tested this on 32bit linux with

  • ubuntu gcc 4.4.5, boost 1.42.0
  • ubuntu gcc 4.5.1, boost 1.42.0
  • debian gcc 4.5.2-8, boost 1.46.1.1
  • debian gcc 4.6.1 20110428 (prerelease), boost 1.46.1.1

The Mono-2.10.2.vmdk image SuSE with

  • gcc 4.5.0 20100604, boost 1.42.0.7.1.1 (from yast2 repo)
  • gcc 4.5.0 20100604, boost 1.46.1 (from source)

Conclusions, hints

All versions tested gave me correct and identical output. Surely there must be something PEBCAK going on? Perhaps repeat my above steps on a fresh VM to see for yourself?

The only thing I can really see going wrong is

  • wrong library paths (dynamically loading (old?) incompatible builds of so's)
  • wrong headers used (resulting in incompatible builds od so's)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文