설치된 징글:
$~/Projects/clang$ sudo apt-get install clang
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
clang
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 0 B/3,590 B of archives.
After this operation, 42.0 kB of additional disk space will be used.
Selecting previously unselected package clang.
(Reading database ... 259453 files and directories currently installed.)
Preparing to unpack .../clang_1%3a3.5-23ubuntu1_i386.deb ...
Unpacking clang (1:3.5-23ubuntu1) ...
Processing triggers for man-db (2.7.0.2-2) ...
Setting up clang (1:3.5-23ubuntu1) ...
컴파일 코드:
$~/Projects/clang$ clang hw.cpp
/tmp/hw-70de0d.o: In function `main':
hw.cpp:(.text+0x8): undefined reference to `std::cout'
hw.cpp:(.text+0x1a): 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*)'
/tmp/hw-70de0d.o: In function `__cxx_global_var_init':
hw.cpp:(.text.startup+0x10): undefined reference to `std::ios_base::Init::Init()'
hw.cpp:(.text.startup+0x16): undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
소스 코드:
#include<iostream>
int main()
{
std::cout<<"Hello,World!\n";
}
clang을 사용하려면 무엇이 더 필요합니까?
답변1
C++ 컴파일러 인 C 컴파일러를 clang++
사용해야 합니다 . 좋다 . 나는 이 컴파일러들이 기본적으로 내부적으로 동일하다고 생각하지만 (다시 마찬가지로 ) 기본적 으로 . 따라서 링커 오류가 발생합니다.clang
clang++
gcc
gcc
clang++
clang