Search code examples
repast-hpc

REPAST HPC WSL Installation leads to boost no being found


When trying to run Repast HPC executables I get the following error:

./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object file: No such file or directory ./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object

In the make file I define the link to boost in an env file with the below:

BOOST_INCLUDE= -I$(HOME)/sfw/Boost/Boost_1.61/include/
BOOST_LIB_DIR= -L$(HOME)/sfw/Boost/Boost_1.61/lib/

This is linked to a make file with the following make file

include ./env

.PHONY: clean
clean:
    rm -f *.o
    rm -f *.exe

.PHONY: compile
compile:
    $(MPICXX) $(BOOST_INCLUDE) -c Main.cpp -o Main.o
    $(MPICXX) $(BOOST_LIB_DIR) -o main.exe Main.o $(BOOST_LIBS)

.PHONY: all
all: clean compile

Boost in tsnow@DESKTOP-IF7CEHL:~/sfw/Boost/Boost_1.61/lib$ so it should link well across.

Any help appreciated, just trying to get a tutorial running.


Solution

  • We typically don't link repast to boost, but rather use rpath to let the model executable know where the boost and repast libraries are. For example in your Makefile:

    REPAST_LIB_DIR = $(REPAST_HOME)/lib
    BOOST_LIB_DIR = $(HOME)/theta/sfw/boost-1.66.0/lib
    RPATHS += -Wl,-rpath -Wl,$(REPAST_LIB_DIR) -Wl,-rpath -Wl,$(BOOST_LIB_DIR)
    

    and then add $(RPATHS) after the list of libraries during linking.

    model : $(EXEC_OBJECTS)
        $(CXXLD) -fopenmp -dynamic $^ $(LIBS) $(RPATHS) -o $(NAME)
    

    Some of those args might not be appropriate for WSL, but hopefully the RPATHS part makes sense.

    So, if after your include directive, you add

    RPATHS=-Wl,-rpath -Wl,$(BOOST_LIB_DIR)
    

    and update the second line of your compile target with

    $(MPICXX) $(BOOST_LIB_DIR) -o main.exe Main.o $(BOOST_LIBS) $(RPATHS)
    

    The location of your boost libs is compiled into main.exe, and it should find it.