Hi,
I just installed GhostBSD 24.10.1 and one of the first things I wanted to try was a C/C++ compiler. So I created a simple hello world app:
#include <iostream>
int main()
{
std::cout << "Hello on FreeBSD!" << std::endl;
return 0;
}
Then I tried to compile it: c++ -v hello.cpp
and it gave me this error:
FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)
Target: x86_64-unknown-freebsd14.1
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/c++" -cc1 -triple x86_64-unknown-freebsd14.1 -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name hello.cpp -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/frantic/Documents -v -fcoverage-compilation-dir=/home/frantic/Documents -resource-dir /usr/lib/clang/18 -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/lib/clang/18/include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/hello-fb7dd0.o -x c++ hello.cpp
clang -cc1 version 18.1.6 based upon LLVM 18.1.6 default target x86_64-unknown-freebsd14.1
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/lib/clang/18/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
End of search list.
hello.cpp:1:10: fatal error: 'iostream' file not found
1 | #include <iostream>
| ~~~~~~
1 error generated.
I thought FreeBSD came with a built-in C/C++ compiler that works, but for some reason only the clang binary seems to work on my machine, not the includes. I also tried to find the iostream header with find / -name iostream
but didn't find anything. What am I doing wrong and how can I fix this?