Linux running source code

So I successfully installed Box2d into my Linux machine then I tried running the HelloWorld.cpp from the default download.
I used
Code:
g++ -c HelloWorld.cpp
g++ -o main HelloWorld.cpp -lBox2D
./main


But an error appears and says
Code:
./main: error while loading shared libraries: libBox2D.so.2.1.0: cannot open shared object file: No such file or directory


I'm not so good with linux and compiling through bash but I want to learn and I'm having trouble wit this error.
It might be that you need to run the 'ldconfig' command (under root) to inform your system of the presence of a new dynamic library.

If that still doesn't work, it might be that you installed the library in a non-standard directory. Then you will need to add that directory path (e.g., /usr/local/lib) to /etc/ld.so.conf, and run 'ldconfig' again.

If you have no access to root privileges, you can use the LD_LIBRARY_PATH environment variable like this:
Code:
LD_LIBRARY_PATH=/some/directory ./main
or like this:
Code:
export LD_LIBRARY_PATH=/some/directory
./main
By the way, you can use the 'ldd main' command to see where the system finds each library required by the program 'main'.

Original thread: https://box2d.org/forum/viewtopic.php?t=6347