Compilation errors using Boost 1.46.1
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)
-
-
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.
-
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.
-
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.
-
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.
-
BTW, you can just add this at the top of the file with some choice "using". No need to escape every usage...
-
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.
-
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.
-
Yes, 'develop' is the right thing to branch from, thanks Adam!
-
Great ! So, the solution is to change everything to not use random?
-
I wanted to check in on this issue, as I'm experiencing the same problems with boost 1.46. Any updates?
-
reporter I've been distracted by other work lately and haven't devoted much time to this. I hope to return to this soon.
-
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.
-
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.
-
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.
-
Issue
#39was marked as a duplicate of this issue. -
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.
-
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:
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.
-
@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.
-
@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)
-
@dkeyes What version of Ubuntu is this? I guess it's the stock compiler on Ubuntu?
-
@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?
-
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.
-
- changed status to resolved
Resolved with 5ecfac348c3e49def1d11ea740cc7b49e0ef5dcc
- Log in to comment
Good catch. Yes, apparently that namespace was only introduced in 1.47, see http://www.boost.org/users/history/version_1_47_0.html Is there a way to check whether the boost version is at least 1.47 and do an ifdef? If so, and you're willing, create a branch feature/random with the change and generate a pull request, then we'll merge.