Skip to content

[cpp] C++ Lang on FreeBSD

[cpp] Clang C++ on FreeBSD

FreeBSD is a complete operating system. It officially supports c++ programming language. Clang c++ compiler has been living in FreeBSD base system for many years. You can use clang to compile c++ code without installing any additional software on FreeBSD.

$ which clang
/usr/bin/clang
$ which clang++
/usr/bin/clang++

And FreeBSD supplies you two basic screen editors, vi/nvi and ee to write any code, which doesn't need to install any additional software too. And there are so many line editors usable on the base system.

$ which vi
/usr/bin/vi
$ which nvi
/usr/bin/nvi

However, if you want a beautify editor you can install vim and so on.

pkg install vim-console

There are some other clang(llvm) c++ compiler distributions available from ports and pkg, you can install them for your special case.

$ pkg search llvm | awk '/^llvm/'
llvm-90                        Meta-port for the default version of the LLVM Toolchain
llvm-cheri-11.0.d20201209      LLVM and Clang with support for the CHERI architecture
llvm-devel-13.0.d20210408_1    LLVM and Clang
llvm-devel-lite-13.0.d20210408_1 LLVM and Clang
llvm10-10.0.1_5                LLVM and Clang
llvm11-11.0.1                  LLVM and Clang
llvm12-12.0.0.r4               LLVM and Clang
llvm70-7.0.1_5                 LLVM and Clang
llvm80-8.0.1_4                 LLVM and Clang
llvm90-9.0.1_3                 LLVM and Clang

Install llvm-devel:

pkg install llvm-devel

And compile your c++ code with the compiler:

# Use latest c++ compiler
clang++-devel your-code.cpp

# Use stable c++ compiler
clang++ your-code.cpp

And many clang/llvm underlying toolchains are avaible on FreeBSD, such as lld, lldb, etc.:

  • FileCheck
  • bugpoint
  • c-index-test
  • clang
  • clang++
  • clang-11
  • clang-apply-replacements
  • clang-change-namespace
  • clang-check
  • clang-cl
  • clang-cpp
  • clang-doc
  • clang-extdef-mapping
  • clang-format
  • clang-include-fixer
  • clang-move
  • clang-offload-bundler
  • clang-offload-wrapper
  • clang-query
  • clang-refactor
  • clang-rename
  • clang-reorder-fields
  • clang-scan-deps
  • clang-tblgen
  • clang-tidy
  • clangd
  • diagtool
  • dsymutil
  • find-all-symbols
  • git-clang-format
  • hmaptool
  • ld
  • ld.lld
  • ld64.lld
  • lit
  • llc
  • lld
  • lld-link
  • lldb
  • lldb-argdumper
  • lldb-instr
  • lldb-server
  • lldb-vscode
  • lli
  • llvm-addr2line
  • llvm-ar
  • llvm-as
  • llvm-bcanalyzer
  • llvm-c-test
  • llvm-cat
  • llvm-cfi-verify
  • llvm-config
  • llvm-cov
  • llvm-cvtres
  • llvm-cxxdump
  • llvm-cxxfilt
  • llvm-cxxmap
  • llvm-diff
  • llvm-dis
  • llvm-dlltool
  • llvm-dwarfdump
  • llvm-dwp
  • llvm-elfabi
  • llvm-exegesis
  • llvm-extract
  • llvm-gsymutil
  • llvm-ifs
  • llvm-install-name-tool
  • llvm-jitlink
  • llvm-lib
  • llvm-link
  • llvm-lipo
  • llvm-lit
  • llvm-lto
  • llvm-lto2
  • llvm-mc
  • llvm-mca
  • llvm-ml
  • llvm-modextract
  • llvm-mt
  • llvm-nm
  • llvm-objcopy
  • llvm-objdump
  • llvm-opt-report
  • llvm-pdbutil
  • llvm-profdata
  • llvm-ranlib
  • llvm-rc
  • llvm-readelf
  • llvm-readobj
  • llvm-reduce
  • llvm-rtdyld
  • llvm-size
  • llvm-split
  • llvm-stress
  • llvm-strings
  • llvm-strip
  • llvm-symbolizer
  • llvm-tblgen
  • llvm-undname
  • llvm-xray
  • modularize
  • obj2yaml
  • opt
  • pp-trace
  • sancov
  • sanstats
  • scan-build
  • scan-view
  • verify-uselistorder
  • wasm-ld
  • yaml2obj

Clang Home: https://clang.llvm.org

 

 

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.

@cppfx.xyz