I installed clang from Software Manager on Linux Mint 20.3 Cinnamon,
I'm trying to build the following example:
#include <iostream>
using namespace std;
int main(){
std::cout << "Hello, world";
}
clang hello.cpp -o hello
/usr/bin/ld: /tmp/hello-017c47.o: in function `main':
hello.cpp:(.text+0xa): undefined reference to `std::cout'
/usr/bin/ld: hello.cpp:(.text+0x1d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: /tmp/hello-017c47.o: in function `__cxx_global_var_init':
hello.cpp:(.text.startup+0xf): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: hello.cpp:(.text.startup+0x15): undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can't compile C++ example
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Can't compile C++ example
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Can't compile C++ example
You need to use
clang++
as your command, not clang
. That's for C code.Re: Can't compile C++ example - SOLVED
That did it. Thank you so much.
Re: Can't compile C++ example
Awesome, mark your topic [SOLVED], thanks!