Are you using vim from the comandline/in the terminal, or are you using
gvim? If you're using gvim, perhaps the environment is different and
causing problems.
> 3) I've used the vimrc file as provided by the llvm project, see
> https://llvm.org/svn/llvm-project/ll...tils/vim/vimrc
URLs with '...' in them are incredibly unhelpful if anybody wants to
look up what you've referenced!
It looks to me like you are trying to link an existing executable
(hello), rather than compiling the source code (hello.c) or linking an
object file (hello.o), and so the linker is finding two copies of all
the system stuff: one copy that is in the executable from the last time
it was linked, and one copy from its attempt to compile it in now.
That's my best guess as to what's happening here, but even that's a
pretty long shot, as usually a linker won't do this, I don't think.
> For clarity both the c and cpp-code compile fine with clang directly
> from the commandline. So the problem must be in the way how I call
> clang from vim (using :set makeprg=clang++ or :set makeprg=clang).
> Hopefully somebody knows what the correct way to do this?
It will be easier to know what's going on and pinpoint the problem and
direct you in the right direction if you could fix the links to the
stuff you are using (or if it's short, include it in the body of your
email), and tell us exactly what commands you are running in Vim, and
how you are starting Vim.
Note also, perhaps it would be smarter to use a makefile, that can
invoke the compiler you want, but not require any change of 'makeprg' in
Vim, only possibly :compiler to correctly interpret the messages.
Cheers,
Ben.
> Are you using vim from the comandline/in the terminal, or are you using
> gvim? If you're using gvim
This is with vim in the commandline, but the same happens with gvim.
> URLs with '...' in them are incredibly unhelpful if anybody wants to
> look up what you've referenced!
Apologies...copy-paste gone wrong:
1) the vimrc I used:
https://llvm.org/svn/llvm-project/llvm/trunk/utils/vim/vimrc
2) post to the llvm-mailing list:
http://markmail.org/message/mq73uxpc7cwpji2k#query:llvm%20vim%20gohman+page:1+mid:ttziiaqgt2oabua6+state:results
> It will be easier to know what's going on and pinpoint the problem and
> direct you in the right direction if you could fix the links to the
> stuff you are using (or if it's short, include it in the body of your
> email), and tell us exactly what commands you are running in Vim, and
> how you are starting Vim.
The fixed links are above, and the commands I used (with a hello world
bit of code):
vim hello.cpp
:set makeprg=clang
:make hello.cpp
for gcc opening the file and typing :make hello works (but not for clang)
>
> Note also, perhaps it would be smarter to use a makefile, that can
> invoke the compiler you want, but not require any change of 'makeprg' in
> Vim, only possibly :compiler to correctly interpret the messages.
I have not yet tried this with a makefile, as I followed the approach
outlined under quickfix here:
http://www.justlinux.com/nhf/Programming/Introduction_to_C_Programming.html
Anyway I would hope that for such as simple compile this could work
with clang without having to figure out makefiles.
vim hello.cpp
:compiler clang
:set makeprg=clang++
:make hello.cpp
while putting the following script in the compiler directory:
http://www.vim.org/scripts/script.php?script_id=3259 works as expected
(although the behavior still differs form compiling with gcc).
I feel stupid for not spotting this sooner. :-( Sorry for the noise!