Compilation errors using Boost 1.46.1

Issue #34 resolved
Adam Rutkowski created an issue

I get the following error when trying to compile gtsam 2.3.1 with boost 1.46.1

.../gtsam-2.3.1/examples/SolverComparer.cpp:488:3: error: ‘mt19937’ is not a member of ‘boost::random’

For me, this can be fixed by changing boost::random::mt19937 to boost::mt19937 in SolverComparer.cpp. I also need to change boost::random::normal_distribution to boost::normal_distribution

On a different machine with boost 1.54.0 installed, I see that random is actually a namespace inside the boost namespace, so everything should work fine with boost 1.54.

I have been playing with gtsam for about a month, and this is my first issue to report. I appreciate being invited to contribute.

Comments (24)

  1. Adam Rutkowski reporter

    I actually wouldn't mind doing this, but I think I only have read access, at least I think that's what "Membership: read" means.

    In boost, there is an include file "version.hpp" that has the version number. I think an ifdef solution would work. Since you would put an ifdef there, what do you think about the possibility of having support for C++11, since the boost random libraries have essentially been absorbed into the new standard? This may require an additional compilation option and may be more trouble than its worth though.

  2. Frank Dellaert

    If you send me a code snippet via this thread @richardroberts or I can add it. Is C++11 pretty standard on compilers these days? I'm a bit worried about supporting embedded platforms and the like.

  3. Richard Roberts

    C++11 is fairly standard in recent compilers but there is definitely limited or no support in compilers for some embedded platforms, nor in older versions of GCC and MSVC. Some users of GTSAM avoid C++11 because it is not supported in the compiler they use for some of their embedded platforms, so for that reason we've also avoided using it.

  4. Richard Roberts

    Adam, I just added you to the "collaborators" group so you should now have write access to GTSAM, i.e. should be able to create a pull request.

  5. Frank Dellaert

    BTW, you can just add this at the top of the file with some choice "using". No need to escape every usage...

  6. Adam Rutkowski reporter

    During our video call yesterday, Richard mentioned that Boost often provides backward compatibility when a major change is made. I looked into this, and sure enough, according to the changelog for boost 1.47, under random,then under compatibility issues, it says "There are also using declarations in namespace boost for everything that was moved."

    So, I tried this in some simple stand alone code on my Windows (gasp) machine with Boost 1.55, and sure enough, boost::mt19937 and boost::normal_distribution work just fine. I think this is the simplest solution since it doesn't require any preprocessor directives, so this is how I intend to update the code.

    As a side note, I discovered that Boost 1.54 doesn't play nicely with Visual Studio 2013. It returns a strange error about an unrecognized compiler. Boost 1.55 works just fine though.

  7. Adam Rutkowski reporter

    Since I'm new to bitbucket, I really don't want to mess anything up. When I create the branch, which version do I branch from? "Develop" comes up as the default.

  8. Daniel K

    I wanted to check in on this issue, as I'm experiencing the same problems with boost 1.46. Any updates?

  9. Adam Rutkowski reporter

    I've been distracted by other work lately and haven't devoted much time to this. I hope to return to this soon.

  10. Daniel K

    Adam will you be able to commit a fix soon? If you're too busy right now, I'll go ahead and make the change, just wanted to check before I started.

  11. Richard Roberts

    Daniel, perhaps if you know how to do the fix you can go ahead and do it. I believe Adam found its only necessary to remove the 'random' namespace usage.

  12. Daniel K

    That's what I figured. I think there might be one other namespace that was also renamed, but I wasn't sure if the problem was more complex than that. I'll go ahead and do it then.

  13. Adam Rutkowski reporter

    Thanks Daniel. I was about to work on this now, but you can go ahead and do it. It really is only two lines of code. Indeed, I think removing the 'random' namespace usage will work.

  14. Daniel K

    Hmm, half the problem was an easy fix (replace boost::random:: with boost:: in Sphere2 and Rot3), but I'm having the same problem with namespace boost::range in , and simply changing the namespace produced a different error:

    http://pastebin.com/YK26sBac

    That's after changing the namespace in HessianFactor.cpp, although I made the same change in JacobianFactor-inl.h without any compilation errors. I don't see why I'm getting that error, but I'm not intimately familiar with boost::range, so maybe I'm missing something.

  15. Richard Roberts

    @dkeyes what compiler are you using? I have reports from others that everything works in boost 1.46.1, so I guess it must be due to the compiler rather than the boost version. Let me know and I'll try to reproduce it.

  16. Daniel K

    @richardroberts Running gcc -v gives:

    #!
    
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
    Target: x86_64-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
    Thread model: posix
    gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
    
  17. Richard Roberts

    @dkeyes I tried to reproduce the 2nd error on Ubuntu 12.04 with gcc 4.6.3 and boost 1.46.1. Everything compiles after only removing 'random'. Is this the same setup you have?

  18. Richard Roberts

    Actually I get compile errors in the 'develop' branch with boost 1.46. Creating a new issue for that and marking this one as resolved.

  19. Log in to comment