1

My C++ project uses CMake for creating makefiles for compilaton and external libraries from 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 in 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 the Environment Modules Project 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.

Community
  • 1
  • 1
Hotschke
  • 9,402
  • 6
  • 46
  • 53

1 Answers1

3

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.

JohnQ
  • 684
  • 6
  • 9
  • thanks for your answer. It was really helpful. Now I could figure it out. It was actually only gvim with linking problems and not vim in the commandline. Actually, I had to set the env variable `$LIBRARY_PATH`: `let $LIBRARY_PATH="/apps/boost/1_50_0/lib/:".$LIBRARY_PATH`. – Hotschke Feb 04 '13 at 09:20
  • Further information for someone with a similar problem, see following websites: [vim.wikia.com/EnvVar](http://vim.wikia.com/wiki/Environment_variables), [ld-library-path-vs-library-path](http://stackoverflow.com/questions/4250624/ld-library-path-vs-library-path) and [Re: gvim - environment/bashrc not loaded](http://vim.1045645.n5.nabble.com/gvim-environment-bashrc-not-loaded-tp1179930p1179931.html) – Hotschke Feb 04 '13 at 09:33
  • Glad that worked for you. Thanks for adding the pointer to the difference between LD_LIBRARY_PATH and LIBRARY_PATH – JohnQ Feb 04 '13 at 21:13