Installing multiple copies of library on Unix - c++

So suppose I have installed the SFML 1.6 C++ library from the Ubuntu repositories. Then I have header files in /usr/include/SFML, library files in /usr/lib etc.
Now I have also downloaded a recent source tarball and built and installed SFML 2.0 into /usr/local.
So by default, if I #include , it gets the SFML 2.0 copy from /usr/local/include. Similarly, it links to libraries from /usr/local/lib.
My question is, how can I tell the compiler/linker to get the files from /usr/include and /usr/lib? I tried
g++ -I/usr/include
but it didn't work. Is this possible at all? Or should I just keep the 'home built' copy in a non system location?

Check the ldconfig command. I guess running it in the destination folder of the newer version of the library should do the trick.

Related

How to force CMake to ignore sytem db.h header file in favour of installed version on Mac?

I'm trying to port my CMake library to mac. I'm linking berkerly DB so I've installed it using brew and I'm able to find the appropriate paths (library, include etc) in cmake. They are
Berkerly
BERKELY_STATIC_LIBRARY /usr/local/lib/libdb.a
BERKELY_lIBRARY /usr/local/lib/libdb.dylib
BERKELY_INCLUDE_DIR /usr/local/include
However, my library doesn't compile because the dependency I am compiling includes db.h
#include <db.h>
which also exists at
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/db.h
and is being used in preference to the one at /usr/local/include. Is it be possible to force CMake to use the db.h from /usr/local/include instead of the other one?

wxWidgets jpeg library build issue

I'm trying to build wxWidgets library into a custom path on a Fedora 27 operative system.
I achieved the wx-config file path recognition and works with the cmake execution. Also, I load libraries and include dirs based on modified wxWidgets finder cmake file that sets thewx-config custom path successfully.
But cmake does not load my wxWidgets configuration. I mean, wx_gtk2u_jpeg-3.1 builded lib could not be founded (suposed to be /usr/lib/libwx_gtk2u_jpeg-3.1.so). I need jpeg dependency from wxWidgets for my project.
I'm sure that problem is not about cmake files. However, the problem is wxWidgets compilation because cmake can found the other builded dependencies into /usr/lib/
I actually installed the libjpeg-turbo-devel package that includes the libjpeg.h needed for wxWidgets building without success of libwx_gtk2u_jpeg-3.1.so creation.
The weirdest part is that $ wx-config --libs shows the wx_gtk2u_jpeg-3.1 lib to be linked and the hint paths that it should be founded.
wxWidgets commands for building:
$ ./configure --with-libjpeg=builtin --with-libpng=builtin --with-libtiff=builtin --with-zlib=builtin --with-expat=builtin --enable-webviewwebkit=no --prefix=/opt/cpp_dependencies/2018Q1/usr'
$ make -j 4
$ make install
You can check out my cmake files, the cmake output and wxWidgets building output in order to reproducing it: https://gist.github.com/jjalvarezl/b70accae269ef56c56010bedf157c27f
You can see line 1543 of wxWidgets building output file that jpeg library is buildin, and, 1564 of same file, the make install command that installs all libwx_<lib_name>.so libraries into final /usr/lib path. Anyway, no one contains the needed library.
Please show the exact error message, as it's not clear what the actual problem is. What I can say, is that the different built-in versions of 3rd party libraries, such as libjpeg, are always static libraries, even when wxWidgets themselves are shared. I.e. you're never going to have libwx_gtk2u_jpeg-3.1.so, only .a.
I'd also strongly recommend using system versions of the 3rd party libraries under Unix systems. This means that your wxWidgets applications will get security updates from your OS vendor and you don't risk running into any incompatibilities due to using 2 different versions of the same library in your application.

Can't find libopecv_core.so.2.3, file actually not there

So I have a question concerning a .so file in Ubuntu. I'm trying to run a program in QT creator, but I get the error
/home/sean/Desktop/iStrabGUI_140321/iStrabGUI: error while loading
shared libraries: libopencv_core.so.2.3:
cannot open shared object file: No such file or directory
My opencv and opencv2 directories are located at /usr/include, and I did add them to my LD_LIBRARY_PATH variable. However, after checking inside the opencv and opencv2 directories, it doesn't seem like the file is there at all. My question is, how do I go about getting this file? I've already installed libopencv-dev on my computer, so where does this come from?
If you really can not find the shared library, it seems to me that you have not installed openCV properly. You might have downloaded openCV but not built the libraries, I assume?
Since you are using Ubuntu you can install openCV from the Ubuntu repository
sudo apt-get install libopencv-dev python-opencv

libboost_python-py27.so.1.53.o No such file or directory

I have one .so library compiled for x86 and I need to deploy and use on another computer(laso Ubuntu), but when I start I get error libboost_python-py27.so.1.53.o No such file or directory, when I ls through /usr/lib I found libboost_python-py27.so.1.49.o . What to do ?
The numbers indicate the version of boost. (See boost.org)
Your code is looking for 1.53, but you only have 1.49 deployed.
You will need to get a copy of the newer libraries and deploy them - for example by getting the relevant version of boost and building the libraries. Or copying them from the machine which has the newer libraries.

C++: How to tell eclipse which version of library to use

I am using ubuntu 12.04 and it has a version of boost (1.46.1)
installed to /usr/lib and include files in /usr/include.
I have compiled my own version (1.51.1) locally and have been using it fine up until now.
I am working on a new project which is using many includes in /usr/include and libs in /usr/lib so in my include path I have /usr/include and /home/aly/libs/boost/stage/include,
similarly in lib search paths I have /usr/lib and /home/aly/libs/boost/stage/lib. However when I add boost libraries to link it seems to be grabbing them from /usr/lib and it causing my code not to work.
If I remove /home/aly/libs/boost/stage/lib and /home/aly/libs/boost/stage/include
it works fine but now can't use the 1.51 features.
Is there an easy way around this problem?