Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

c++ - Installing ccls through Homebrew outputs caveats messages related to libffi and llvm

I'm trying to set my neovim C++ development environment, and want to use ccls as my coc language server.

When I installed ccls using Homebrew, it installs libffi and llvm as dependencies. It seems like ccls is installed successfully, but it seems like I need to configure PATH variable,LDFLAGS and CPPFLAGS.

But I don't know what libffi and llvm are for, and they suggest different LDFLAGS and CPPFLAGS, which is confusing.

Is it okay not to export any variables to use ccls? Or, which version should I export in my ~/.zshrc?

Below is my console output for brew install ccls.

? brew install ccls
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.3.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/llvm-11.0.0_1.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c8e30903a9a4f695780e1eeeaa2cf4d5a95141a1cac98ab1bbc811817cde39ca?response-content-disposition=attachment%3Bfilename%3D
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/ccls-0.20201219.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/934fb8fd594d6e7adbfa14b5608f1de14309db34f2cf61a0cb572bdc772b2aa3?response-content-disposition=attachment%3Bfilename%3D
######################################################################## 100.0%
==> Installing dependencies for ccls: libffi and llvm
==> Installing ccls dependency: libffi
==> Pouring libffi-3.3.big_sur.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"
  export CPPFLAGS="-I/usr/local/opt/libffi/include"

==> Summary
??  /usr/local/Cellar/libffi/3.3: 17 files, 540.2KB
==> Installing ccls dependency: llvm
==> Pouring llvm-11.0.0_1.big_sur.bottle.tar.gz
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"

==> Summary
??  /usr/local/Cellar/llvm/11.0.0_1: 8,922 files, 1.4GB
==> Installing ccls
==> Pouring ccls-0.20201219.big_sur.bottle.tar.gz
??  /usr/local/Cellar/ccls/0.20201219: 5 files, 1.5MB
==> Caveats
==> libffi
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"
  export CPPFLAGS="-I/usr/local/opt/libffi/include"

==> llvm
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

libffi is only a library. And llvm is a compiler infrastructure. And libc++ is the C++ standard library of the LLVM Project. You can use the LLVM library or the GNU (libstdc++) one. It depends on your software project (or your personal preferences) what library you use.

Since macOS does already deliver a llvm installation you can optionally switch to the one installed as dependency by brew – which is not required.

The LDFLAGS environment variable does hold additional flags which is passed by your compiler (gcc/g++ or clang/clang++) to the linker, i.e. adding the path where the linker can find the library object files which are then, if required/used, linked against your binary.

And CPPFLAGS does the same, but this time the flags are targeting the compiler directly, i.e. adding an additional search path for the header files of the library.

And in your case you don't have to export any (additional) variables from your .zshrc, ccls will work fine for you without defining those variables.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...