Boost-Extension-Reflection How to fix segmentation fault error when compiling official sample not with bjam?

大城市里の小女人 提交于 2019-12-13 07:03:44

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/5847769/boost-extension-reflection-how-to-fix-segmentation-fault-error-when-compiling-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!