It’s still not clear to me whether to categorize your question as a DEVELOPMENT issue or a DEPLOYMENT issue. Normally tweaking things in /etc are for more than a personal impact. But the repeated reference to –ltbb leads me to a link error, not a load error.
There’s lots of resources in print and on the web regarding Linux development, but I’ll share with you a bit of the infrastructure I’ve been using for my current blog series. I needed access to Intel TBB features not in any published binary so I needed to build my own an link them in. I didn’t want to have to construct a Makefile from scratch (there’s probably some tool for automating it) so I just built a batch file:
#\!/bin/bash
export LD_LIBRARY_PATH=../../TBB/tbb20_20080408oss_src/build/linux_em64t_gcc_cc4.1.2_libc2.5_kernel2.6.18_debug
gcc -g -o nested_dbg -I../../TBB/tbb20_20080408oss_src/include -I/usr/include -L ../../TBB/tbb20_20080408oss_src/build/l
inux_em64t_gcc_cc4.1.2_libc2.5_kernel2.6.18_debug -ltbb_debug -lstdc++ nested.cpp
export LD_LIBRARY_PATH=../../TBB/tbb20_20080408oss_src/build/linux_em64t_gcc_cc4.1.2_libc2.5_kernel2.6.18_release
gcc -o nested -I../../TBB/tbb20_20080408oss_src/include -I/usr/include -L ../../TBB/tbb20_20080408oss_src/build/linux_em
64t_gcc_cc4.1.2_libc2.5_kernel2.6.18_release -ltbb -lstdc++ nested.cpp
This sets the minimum required environment to link from my project directory to the location of the Intel TBB build that I did, linking both include files and library objects with the usual syntax to specify include paths and library paths. These set the library for the build but not necessarily for the parent shell. Failing to set LD_LIBRARY_PATH would result in an error like this:
$ ./nested
./nested: error while loading shared libraries: libtbb.so: cannot open shared object file: No such file or directory
That’s easily corrected by issuing the correct export line for optimized or debug in the parent shell. Ah, but there was an issue of using the Intel compiler. I experimented with that, sourced an environment for the Intel compiler (/opt/intel/cce/10.1.013/bin/iccvars.sh or whatever), then ran the script again and got:
$ ./nested
./nested: error while loading shared libraries: libcxaguard.so.5: cannot open shared object file: No such file or directory
This is because I managed to lose the link to the compiler library in my LD_LIBRARY_PATH because of an inadvertent sourcing of one of the export lines above. The solution to that was just to add the compiler library to the build script.
Regarding my “export MY_ETCBASH” suggestion, if you read the initialization section of the bash man page you’ll see several files that may be read depending on particular conditions, and after too many assumptions proved wrong, I decided to add these notations to the heads of several of these files, just so I could check whether the shell I was running at the moment actually had the benefit of a particular file. I might add “export MY_ETCBASHRC=1” to the start of /etc/bashrc and then be able to check whether MY_ETCBASHRC is defined in a particular shell. This became especially handy when I built a multi-environment shell initialization to handle different machine architectures and *NIX flavors, including MKS and SFU on Windows plus Linux.