Linking problem to libraries installed with Homebrew since Mojave update - c++

I have recently updated to Mojave and since then am experiencing linking problems to libraries (gsl, Cuba etc.) that I had installed with Homebrew.
When compiling my code, gcc (tried g++-6 and g++-8, also installed with brew) does not seem to search the directories where brew stores the header files for those libraries. The code compiled when I manually set the paths to
GSL_INCLUDE_PATH=/usr/local/include/gsl/
GSL_LIB_PATH=/usr/local/lib/
CUBA_PATH=/usr/local/include/
But since I am using this in all my make-files I do not want to do this every time...
Before I was using Sierra and I have included in my .bash_profile the following:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
This seemed to do the trick before. But now /usr/local/sbin did not exist anymore. I ran brew doctor which suggested:
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/Frameworks /usr/local/sbin
sudo chown -R $(whoami) /usr/local/Frameworks /usr/local/sbin
I did just that and reinstalled the libraries but it did not sort out the issue.
I have tried to include
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/include:/usr/local/lib:$PATH
in the bash-profile, but that did not help either. (Maybe I did it wrong, I am not familiar with setting paths) At this point I am not sure whether brew installs the libraries in a weird place or if gcc just does not look in the correct location.
I have installed Xcode and the command tools. I have tried everything I found (and could understand) that I found as solutions for related problems.
I would like for gcc to look in the directories that brew installs the libraries to by default.
I would be really grateful for a suggestion of a clean fix for this issue.
Please excuse the long essay; if you need additional information please do tell, this ist my first time asking for help here.

Related

ldconfig command reverts to previous library version

I've been playing with this library for the Raspberry Pi (Raspian/DietPi - Jessie) and ran into a peculiar situation. I made some local changes, built, and installed the library like so:
cmake ..
sudo make install
sudo ldconfig
However later I made a correction to the library then built and installed the library, but did not run the 'ldconfig' command. I ran my program that uses these dynamically linked libraries and it worked with the updated libraries.
However, I then realized I forgot 'sudo ldconfig' and after executing it, the program was clearly running with the previous library version. I repeated this several times and had to actually use 'ldconfig -p' to find where the .so files were and delete them so that the next ldconfig would use the latest files, and then the problem was resolved.
Why would 'sudo ldconfig' grab a previous version of these build libraries, and where would it grab them from?
You can add your current lib path to etc/ld.so.conf and then run ldconfig again.
Or you can add to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/new/path/newpath

VisualGDB c++ to RaPi Poco no such file or directory

I am taking over a project and am pretty new with this entire setup (linux/gdb/c++). This project did work at 1 point, on RaPi 1.
Using VisualGdb to compile a c++ program to run on a RaspberryPi 2. I've seen similar questions, but either the answers didn't work or I don't fully understand how to implement.
When I try to compile, I get a fatal error: library name: No such file or directory.
2 that I know of so far are:
include "Poco/Data/Common.h"
include "Poco/Data/SQLite/Connector.h"
I have a similar program that uses different poco libraries and it compiles fine. If I look in the External Dependencies of the project, I see Common.h and Connector.h. The GDB Makefile settings have pthread PocoFoundation PocoData PocoDatad PocoDataSQLite PocoDataSQLited libraries listed.
Tried a few things, but not really sure how to debug this. I don't seem to be able to find the files on the RaPi using find -iname "Common.h", but I can't find the ones that are working in the other project either using that method.
I've done the Complete Edition install of poco and run sudo apt-get update; sudo apt-get upgrade; sudo rpi-update.
Tried to give as much info as I understand of this, but sure I missed something. Any help/suggestions would be great. Let me know if you need more info on something I didn't include.
Thanx ahead of time.
In case anyone else has this issue.
libmysqlclient-dev needs to be installed first for these libraries to get installed with the poco install.

What does "/usr/lib/libstdc .so.6: version `GLIBCXX_3.4.15' not found" mean, and how do I fix it?

I'm new to compiling libraries .so under Ubuntu. I have the source, .cpp file. I installed the build-essentials package finely, and I'm using the Anjuta IDE to compile the source code. I have the Makefile and everything is good.
Now although it compiles without error, when I load it, I get the error:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found`
What does this mean and how can I fix it?
Edit: Any more tips?
Edit2: I really need help guys.
I had similar issues and I tried (https://askubuntu.com/questions/164296/glibcxx-3-4-15-not-found):
sudo apt-get install libstdc++6
optionally you can force a global update of all the linked libraries with
sudo ldconfig
this last command can take some time and will not print anything on the bash, just wait.
Sounds like a dependency problem, is your system up to date?
apt-get install && apt-get upgrade
One way to work around this issue is to simply link libstdc++ statically (with this parameter sent to g++ when linking the executable):
-static-libstdc++
If linking in the library statically is an option this is probably the quickest work-around.

why can't I to install boost in /usr/include?

I'm trying to install boost into include directory for avoid -I flag use in each g++ compiler call,I installed using this command line: ./bjam --prefix=/usr/include install
see --prefix value, it install in /home/myusername, why?
Thanks in advance.
You would need root permissions to install in /usr/include.
Actually your system has done you a favor by not letting you do that. The --prefix option says where to install everything -- headers, libraries, executables, documentation, etc. For example, the header files would be installed in /usr/include/include, which is not going to be in your compiler's search path.
Disclaimer:: This assume that ./bjam --prefix=... behaves similarly to ./configure --prefix=.... I haven't actually used bjam. If bjam's --prefix option means something else, please correct me.
Depending on your system, you may be able to install Boost from a repository rather than building it from source. For Debian or Ubuntu, for example, something like sudo apt-get install libboost might work.
Note that I said something like that; it appears that Boost consists of a number of packages; apt-cache search boost, or better yet, do a Google search to see how to install Boost on your particular system.
Try running
sudo ./bjam
Doing this should run bjam with appropriate privileges to install to /usr/local/include and /usr/local/lib, both of which should be in your search path...

Build Boost on Mac with Xcode

I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :(
What's the sequence of actions to build and use Boost libraries in Xcode?
The easiest way I've found to do it is to install MacPorts, then you can install/build Boost via a single command:
sudo port install boost
Plus you get similar access to other open source software. The only downside I've found is that, like any other package management system, they are not always up to date with the latest version.
If you prefer Homebrew as your package manager, the command is:
brew install boost
I don't know how to use Boost from XCode (I'm not a Mac programmer), but building boost is usually done through their own build tool, bjam.
They have a guide to building boost here, and you can download the latest version of bjam here
Once it is built, you reference it from Xcode the same way you would any other library. The boost/include should be added to your include path, and the libraries in boost/lib can be referenced for the boost libs that require it.
To build boost on a mac, follow the unix variants getting started page (http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html). You won't use Xcode directly to perform the build, but once complete you can add the boost include paths and dylib's to your Xcode project.
I found that to build Boost 1.41.1 on MacOS, you need to do the following:
Download boost 1.46.1 from here: http://sourceforge.net/projects/boost/files/boost/1.46.1/
Unpack the file
Open terminal, cd to the install directory, and do the following:
chmod u+x configure.sh
cd tools/build/v2/engine/src
chmod u+x build.sh
Then go back to the install directory, and:
./configure.sh
If that runs successfully, it will tell you to run:
./bjam
That's it.. for whatever reason, I needed to set those permissions manually before it would work.
su - root
enter root password and then run below as root
/opt/local/bin/port install boost
If you have never logged in as root or forgotten your password, here are the steps to reset root password
http://support.apple.com/kb/HT1528?viewlocale=en_US&locale=en_US
For most of the boost libraries, there's nothing to build, it's all in header files.
The remainder of the instructions are here.
Currently I'm very happy with using Pete Goodliffe's script which builds a framework from the Boost source package for both iOS and Mac. Drag and drop it into a project and it works!
There are multiple versions of the script out there. Here's one:
https://gist.github.com/faithfracture/c629ae4c7168216a9856/61be257e1c0839c85743777d0687becad9913bf7
Elaboration of Ferrucio's answer:
Install Boost using MacPorts (sudo port install boost) or Homebrew (brew install boost).
Find the path to the Boost header files (it should be in /opt/homebrew/include if you're using Homebrew).
Add the path to System Header Search Paths in the Build Settings of your Xcode target.
IMPORTANT NOTE: If you add the path to User Header Search Paths instead of System Header Search Paths, as other users suggested, then your code will fail to build, since the Boost files use angled-includes (#include <boost/filename.hpp>) to include each other. Angled-includes are only for including system library headers, and thus they only work if Boost is in the System Header Search Paths.
You can read about the difference between angled-includes and quoted-includes here.