Issue
My C++ project uses CMake for creating makefiles for compilaton and external libraries from rel="nofollow noreferrer">boost. My editor of choice is vim.
Running $ make
in the command line works but :make
in vim has problems at the linking stage and returns:
/usr/bin/ld: cannot find -lboost_system
However, I also use :make install
to place my project in $HOME/usr/stow/<prog>
where I test and use the program. Therefore I am looking for a solution to make the linking stage successful.
Further details:
It is an out-of-src build dir. Therefore I've configured makeprg
:set makeprg=make\ -C\ ../build/Release/
A more recent boost version is installed and made available on the system via Environment Modules which I rely on in my project. The newer boost version can be loaded via
$ module load boost
I have added this line to my $HOME/.profile
, so that I don't have to call it each time I am compiling.
I have checked the question (G)VIM uses a different $PATH than my system discussing Environment variables as used in vim.
UPDATE: The problem occurred only in gvim started from the window manager(gnome2) and not (g)vim started from the commandline/bash.
Solution
If it works at the command line, but not in vim, see what's different in your environment
:!env | sort > env-vim
then
$ env | sort | diff env-vim -
It's likely something is setting the LD_LIBRARY_PATH to include a non-standard directory for your boost libraries and that's not showing up in the subshell environment of vim. Perhaps you're launching vim from a desktop icon rather than the command line? (vim / :make from the command line would be an interesting test if that's the case).
To get a variable into the vim subshell, add it to the ~/.vimrc
let $LD_LIBRARY_PATH="*your library path*"
I would have commented rather than answered, but I haven't earned that ability, yet. Since it was asked yesterday I gave it shot.
Answered By - JohnQ Answer Checked By - Mary Flores (WPSolving Volunteer)