Closed grandtiger closed 6 years ago
Looks like a linking issue; where did you install the actual library?
The library and test files should build with g++ 5, 6, and 7 (per Travis) and clang 5 and 6.
@kthohr I simply followed your instruction:
# clone mcmc into the current directory
git clone https://github.com/kthohr/mcmc ./mcmc
# build and install
cd ./mcmc
./configure
make
sudo make install
It's installed to /usr/local/lib. I also did
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
What else did I miss? Thanks a lot for looking into this.
@kthohr BTW, I am trying out Ubuntu 18.04 beta and it has gcc 7.3.0. I changed the command to the following, and it compiled successfully.
g++ -std=c++11 -fPIC -O3 -march=native -ffp-contract=fast -flto -DARMA_NO_DEBUG -fPIC -shared -I./include -L/usr/local/lib mcmc_sample.cpp
However, when I tried to run it, I got
./a.out
Segmentation fault (core dumped)
How can I get more information about the root cause of the error?
BTW, what is your development environment? I would like to use virtual machine to mimic your development environment and see if I can get the sample working. Thanks again for any help you may render!
You haven't actually linked to libmcmc with this line:
g++ -std=c++11 -fPIC -O3 -march=native -ffp-contract=fast -flto -DARMA_NO_DEBUG -fPIC -shared -I./include -L/usr/local/lib mcmc_sample.cpp
I just changed two of the test build scripts; let's see if the test suite will run your system. Can you change directory to where you cloned the library and pull the changes:
cd ./mcmc
git pull
Then run (from the same directory):
./configure
make clean
make
sudo make install
cd ./tests/unit_tests
./configure
make
Works on my Linux machine (distro: Fedora 27).
@kthohr Here is what I got. Does it match your output?
george@ubuntu:~/GitHub/mcmc/tests/unit_tests$ make
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. log_jacobian.cpp -o log_jacobian.test -L/usr/local/lib -lmcmc -lblas -llapack
log_jacobian.cpp: In function ‘int main()’:
log_jacobian.cpp:48:12: warning: unused variable ‘lj_val’ [-Wunused-variable]
double lj_val = mcmc::log_jacobian(vals_trans,bounds_type,lb,ub);
^~~~~~
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. aees.cpp -o aees.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. mala.cpp -o mala.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. determine_bounds_type.cpp -o determine_bounds_type.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. rmhmc.cpp -o rmhmc.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. de.cpp -o de.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. rwmh.cpp -o rwmh.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. transform_vals.cpp -o transform_vals.test -L/usr/local/lib -lmcmc -lblas -llapack
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. hmc.cpp -o hmc.test -L/usr/local/lib -lmcmc -lblas -llapack
@kthohr looking at the test output, I changed the command to:
g++ -std=c++11 -Wall -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG -I/home/george/GitHub/mcmc/tests/unit_tests/../../include -I. mcmc_sample.cpp -L/usr/local/lib -lmcmc -lblas -llapack
it compiles, and I can run it ./a.out and there is no more core dump. I added some output to the sample, and it seems to work now. Thanks a lot for pointing me to the right direction.
Great, happy it worked.
I put the sample code into mcmc_sample.cpp and tried to compile it with the following command:
but kept getting the following error:
Following is the info about my ubuntu linux and g++.
What is the minimum version of g++ required by this project? Thanks!