Boost.MPI on Ubuntu 12.04 - c++

Background
Hi All,
I'm trying to use Boost::MPI, at the moment I'm just trying to run the simple first example from the tutorial. I am having trouble building/running it.
I installed boost using apt-get and installed boost_mpi & boost_serialization (1.48.0) using synaptic package manager. I installed MPICH2 using apt-get.
Even though OpenMPI was never explicitly installed it appears to be on my system, I assume this is a dependency for Boost::MPI but it appears MPICH2 and OpenMPI are treading on each other's toes.
Info
If I build using
g++ test.cpp -I/usr/include/mpich2 -L/usr/lib -lboost_mpi -lboost_serialization
then run using
mpiexec -n 2 ./a.out
It throws a bunch of errors which seem to come from OpenMPI. If I try and build by linking against the OpenMPI library using
g++ test.cpp -L/usr/lib -lboost_mpi -lboost_serialization -lmpi -I/usr/include/openmpi
I get the following errors:
/usr/bin/ld: /tmp/ccJ5ezv7.o: undefined reference to symbol 'ompi_op_set_cxx_callback'
/usr/bin/ld: note: 'ompi_op_set_cxx_callback' is defined in DSO /usr/lib/libmpi.so.0 so try adding it to the linker command line
/usr/lib/libmpi.so.0: could not read symbols: Invalid operation
If I try building using mpic++ with the following command
mpic++ test.cpp -lboost_mpi -lboost_serialization
It will not link returning a bunch of errors of the form
/usr/lib/libmpich.so: undefined reference to `MPL_trid'
so I tried linking against libmpi i.e.
mpic++ test.cpp -lboost_mpi -lboost_serialization -lmpi
This builds but on running with mpiexec yields the following errors
Fatal error in PMPI_Errhandler_set: Invalid communicator, error stack:
PMPI_Errhandler_set(118): MPI_Errhandler_set(comm=0x370500, errh=0x370be0) failed
PMPI_Errhandler_set(70).: Invalid communicator
Question
It seems to me that somehow OpenMPI and MPICH2 are getting intertwined where there really shouldn't. Does anybody know how I can build against only OpenMPI or MPICH2 then run using the correct mpiexec?

Mixing code compiled against different MPI libraries is not supported in general. If your Boost::MPI is linked against Open MPI, then you must use Open MPI for the rest of your application.
To get the mpic++ as well as the other compiler wrappers and all the header files you should install the -dev package for Open MPI. If the library has been installed as a dependency then only the run-time part will be there.

Related

How can I fix my OpenGL build environment on OSX?

UPDATE
I've sorted this by explicitly adding the appropriate -I and -L options, but I'm curious as to why this is necessary now when it wasn't before? On the plus side those annoying library out-of-sync warnings are gone.
UPDATE ENDS
I've broken my OSX OpenGL build environment. I'm building from terminal (using make) with g++, for example:
g++ -o myprog main.o -lglfw -lglew -framework OpenGL
and getting errors:
ld: library not found for -lglfw clang: error: linker command failed with exit code 1 (use -v to see invocation)
These are in addition to compiler errors such as:
g++ -c main.cpp main.cpp:3:10: fatal error: 'GL/glew.h' file not found
So it seems the OpenGL libraries and includes have been lost. Everything was working fine until I executed the command:
export SDKROOT="$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
Which I did to try and fix warning messages like:
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
I got that 'fix' from here: macOS framework lib problem
I realise it was reckless running commands that I don't fully understand but nonetheless... now I can't compile/link any OpenGL code and after scouring the internet for help I've come up with nothing, so here I am.
I'm running OSX 10.13.6 on a 2013 MacBook Pro.
First post BTW so please forgive me if I've not provided enough detail.

libgtest.so error adding symbols: DSO missing from command line

I have been using gtests for unit testing a personal project. Last week I upgraded to the LTS version of Linux Mint. Unfortunately, after that event, I haven't been able to compile my project due to gtests linking problems.
The following error is being issued:
/usr/bin/x86_64-linux-gnu-ld: build/tests/policies/roundrobin_tests.o: undefined reference to symbol '_ZN7testing4TestC2Ev'
/home/myuser/Documents/googletest-release-1.8.0/googletest/libgtest.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I have generated both libgtest.so and libgtest_main.so through CMake 3.10.2. The gtest version is the release-1.8.0, the same I used to have before.
Those libraries are located in /usr/lib and the corresponding include folder has also been copied to /usr/include. I made sure that this location is in my ld path and that is not the problem.
My compiler is g++ v7.3.0 and the command Im using to compile the testes is:
g++ -std=c++14 -Wall -O3 -Iinclude build/tests/policies/roundrobin_tests.o -lgtest_main -pthread -o bin/policies/roundrobin_tests
I have tried altering the order of the elements in the command, explicitly adding -L/usr/lib and -I/usr/include without luck. A funny fact is that if I take off the -pthread flag, the error is still the same.
The same command was used before and the only difference is the compiler version I am using now as I used g++ 5.4.0 before. Any insights on how to solve this?
edit: Just tested the same process with g++ 5.4.0 and CMake 3.5 and the same problems ocurred.

Fresh installation of bullet physics engine is not linking properly?

Have a relatively new and fresh installation of ubuntu LTS, I followed the instructions found here for generic dynamic library building: http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Installation
Installation appears to go smoothly (no errors or warnings) and afterwards I have all of the necessary files located in /usr/local/include/bullet. I'm currently attempting to compile a file from the following shell command:
g++ bulletTest.cpp -lGL -lGLU -I /usr/local/include/bullet/
bulletTest.cpp is:
#include <iostream>
#include <btBulletDynamicsCommon.h>
int main (void)
{
btBroadphaseInterface* broadphase;
return 0;
}
This file has nothing to it, but is throwing a plethora of undefined reference errors, such as "/tmp/ccH09wLR.o:(.rodata._ZTV17btTypedConstraint[_ZTV17btTypedConstraint]+0x30): undefined reference to `__cxa_pure_virtual'" I cannot find any other complaints on the forums/SO so I believe it must be a problem with my build/installation. These types of errors occur while attempting both gcc and g++ compilers.
Anybody have an idea?
EDIT: changed my shell command to g++ bulletTest.cpp -lGL -lGLU -lBulletDynamics -lBulletCollision -lBulletSoftBody -lLinearMath -I /usr/local/include/bullet/
It compiles but does not run, error is: error while loading shared libraries: libBulletDynamics.so.2.82: cannot open shared object file: No such file or directory
So it was a lot of little stuff. Firstly, don't reference "lbullet" reference each of the libraries needed:
g++ bulletTest.cpp -o bulletTest -lGL -lGLU -lBulletDynamics -lBulletCollision -lBulletSoftBody -lLinearMath -I /usr/local/include/bullet/
In addition, I had to set the LD_LIBRARY_PATH variable
export LD_LIBRARY_PATH=/usr/local/lib
and then it would both compile and run.

Libc++ linked programs fail with symbol lookup error

I've recently built libc++ from scratch as my prject needs some features that are not yet implemnted in libstdc++.
I try to compile the hello world program located in src/main.cpp with line
clang -Wall -stdlib=libc++ -std=c++11 -c src/main.cpp -obuild/main.o
and the build suceeds
Then I link it with
clang -lc++ build/main.o -o qasix
and the linking suceeds too.
But when I run the program with
./qasix
I get the following error:
./qasix: symbol lookup error: /usr/local/lib/libc++.so.1: undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
I would like to know why this is occurring and also how to fix it.
I am on Xubuntu 13.10 if that's of any help.
PS: This problem popped up yesterday. Earlier other libc++ programs would compile fine.
This started when I did a debug build of a program with the -g flag and it compiled and ran fine, but all later programs complained about this symbol lookup failure. Please help.
it appears that you need the support library "libc++abi". It provides things like low-level exception support, type_info support, etc.
For Ubuntu (as opposed to Xubuntu), it appears that you can get it here: http://www.ubuntuupdates.org/package/core/saucy/universe/base/libc++abi-dev

RInside segmentation fault and linking issue

I'm trying to call R from c++ on linux via RInside, I compiled R-2.15.1 from source with gcc version 4.5.3 (Debian 4.5.3-1) , I don't have sudo rights to use apt-get install. I'm using OpenBlas and a system optimized lapack. The blas and lapack libraries work fine for many scalapack applications
I installed R with
./configure --with-blas="-I/lib/OpenBLAS-v0.2.3-0/xianyi-OpenBLAS-48f075c/install/include -L/lib/OpenBLAS-v0.2.3-0/xianyi-OpenBLAS-48f075c/install/lib -lopenblas -lgfortran" --with-lapack="/usr/lib/liblapack.so -lgfortran" --enable-BLAS-shlib=yes --enable-R-shlib --enable-R-static-lib --prefix= .
which installed and runs fine,I ran make check with no errors, also all the packages (Rcpp and RInside) installed fine..
however when i use the given RInside makefile , the basic hello world example from /standard/rinside_sample0.cpp compiles! but it does not run and i get the following error
./rinside_sample0: error while loading shared libraries: libRblas.so: cannot open shared object file: No such file or directory
the file libRblas.so exists and is in the R/lib folder,
when i try to link it manually with the g++ command the make file creates or linking as follows i get a segmentation fault
/R/lib/libRblas.so ./hello_world
Segmentation fault
EDIT: heres how the example make file tries to compile an example, (which compiles fine) but won't run with the above missing libRblas.so error
g++ -I/nfs/user03/jimmie21/libs/lib64/R/include -I/nfs/user03/jimmie21/libs/lib64/R/library/Rcpp/include -I/nfs/user03/jimmie21/libs/lib64/R/library/RInside/include -g -O2 -Wall -I/usr/local/include hello_world.cpp -L/nfs/user03/jimmie21/libs/lib64/R/lib -lR -L/nfs/user03/jimmie21/libs/lib64/R/lib -lRblas -L/nfs/user03/jimmie21/libs/lib64/R/lib -lRlapack -L/nfs/user03/jimmie21/libs/lib64/R/lib -lRblas -L/nfs/user03/jimmie21/libs/lib64/R/library/Rcpp/lib -lRcpp -Wl,-rpath,/nfs/user03/jimmie21/libs/lib64/R/library/Rcpp/lib -L/nfs/user03/jimmie21/libs/lib64/R/library/RInside/lib -lRInside -Wl,-rpath,/nfs/user03/jimmie21/libs/lib64/R/library/RInside/lib -o hello_world
Couple of things:
Reproducible examples, please
You have a non-standard setup
With the script from 1), try it on a standard setting as that is how Rcpp / RInside get developed and tested (on Ubuntu / Debian)
The Rcpp test suite now contains almost 800 unit tests from around 350 unit test functions. These do not seg.fault, so the issue is at your end. Similarly, RInside has dozens of examples in the four examples/ subdirectories. This also works.
It may be as easy as tweaking the Makefile / Makevars files to make sure you get your libraries in all cases. But we can't tell as there is nothing reproducible here.
Edit If you want to link with libRblas.so then you have a completely non-standard setup as the R packages for Debian / Ubuntu as use the external BLAS. Again, not an RInside issue.
I fixed the problem by adding the R install path lib ../R/lib: to the beginning of LD_LIBRARY_PATH after that all the examples compiled and run fine