how to successfully run a c++ file which uses ogdf libraries

447 views Asked by At

I compiled the file (source.cpp) using the command

g++ -I/home/hrishikesh/Desktop/OGDF-snapshot/include -O2 source.cpp -o mytest -L/home/hrishikesh/Desktop/OGDF-snapshot/_release -lOGDF -lCOIN -pthread

and it got compiled successfully without giving any error message,resulting a file "mytest" in the same folder as the source.cpp in. when I try to run the mytest file using command

./mytest

it shows this error message

./mytest: error while loading shared libraries: libOGDF.so: cannot open shared object file: No such file or directory

please help

2

There are 2 answers

0
hrkz On

You need to put libOGDF.so in the same folder than mytest

0
ankit agarwal On

g++ -I /AbsolutePath/Desktop/OGDF/ main.cpp -L -l /AbsolutePath/Desktop/OGDF/_release/libOGDF.a -lpthread

here main.cpp is the file. copy and paste the line above in other text editors to get rid of the confusions between the usage of I and L and the spaces.

Be sure that you are writing the absolute path correct. The a.out file will be generated in current directory. execute it by using: ./a.out