0

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.

Rella
  • 65,003
  • 109
  • 363
  • 636

1 Answers1

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)
sehe
  • 374,641
  • 47
  • 450
  • 633
  • So my boost version is 1.46.1 (compiled from source from [Boost downloads](http://www.boost.org/users/download/) (on Win and Lin). Can you try it on Windows? (I have same problem on both Win and Lin.) See my GCC props in post update. – Rella May 01 '11 at 16:22
  • **Yes it works everywhere I tested**; windows is a different matter: windows itself doesn't work for me (even aside from my aversion, that is) so you're on your own there. I've simplified the steps to reproduce further, perhaps you can do the same in your question? – sehe May 02 '11 at 00:20
  • Its some kind of magic... I have downloaded newer Linux image and it worked!!! Thanks for all work you have done. So it means on windows it probably crashes for some other reason... So I'll get into it!) Thank you very much again!=) – Rella May 02 '11 at 00:22
  • If you're interested you can use gdb to break when the segfault occurs, and use the `bt` command to see where that was. Also, you can use `strace` to see precisely which files are loaded from where, so you can spot any conflicting library versions. Cheers – sehe May 02 '11 at 06:29
  • So... today we finally made it compilable on both Windows and Linux... Actually windows did not liked [absence of ONE symbol](http://code.google.com/p/cloudobserver/source/diff?spec=svn1116&r=1116&format=side&path=/branches/v0.4/Boost.Extension.Tutorial/src/lib-interoperability/cars.cpp) - function we used to provide reflection map were operating on copy of provided map - not on reference. Now it operates on reference - works perfectly under both Windows and Linux=) Will probably test Mac OS X today... – Rella May 02 '11 at 18:37