C+的编译错误+;(马科斯) 当我试图在MAC中编译这个非常简单的C++程序时,我得到了一个错误(HysieRa:Voice 10:133)。此Mac中使用的gcc版本为5.3.0 这是C++程序: #include<iostream> #include<cmath> #include<fstream> using namespace std; int main() { cout<<sin(1); }
我得到以下错误:C+的编译错误+;(马科斯) 当我试图在MAC中编译这个非常简单的C++程序时,我得到了一个错误(HysieRa:Voice 10:133)。此Mac中使用的gcc版本为5.3.0 这是C++程序: #include<iostream> #include<cmath> #include<fstream> using namespace std; int main() { cout<<sin(1); },c++,macos,gcc,compilation,g++,C++,Macos,Gcc,Compilation,G++,我得到以下错误: /var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccGJEHr7.s:24:11: warning: section "__textcoal_nt" is deprecated .section __TEXT,__textcoal_nt,coalesced,pure_instructions ^ ~~~~~~~~~~~~~ /var/folders/mp/z7xpkw3538z719
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccGJEHr7.s:24:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccGJEHr7.s:24:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
Undefined symbols for architecture x86_64:
"std::basic_ostream<char, std::char_traits<char> >::operator<<(double)", referenced from:
_main in ccpjcybF.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccpjcybF.o
"std::ios_base::Init::~Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccpjcybF.o
"std::cout", referenced from:
_main in ccpjcybF.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccJjEuJy.s:24:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccJjEuJy.s:24:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
现在,我得到以下错误:
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccGJEHr7.s:24:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccGJEHr7.s:24:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
Undefined symbols for architecture x86_64:
"std::basic_ostream<char, std::char_traits<char> >::operator<<(double)", referenced from:
_main in ccpjcybF.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccpjcybF.o
"std::ios_base::Init::~Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccpjcybF.o
"std::cout", referenced from:
_main in ccpjcybF.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccJjEuJy.s:24:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/mp/z7xpkw3538z71904cdqhztv00000gn/T//ccJjEuJy.s:24:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
您可以尝试使用
g++
:
g++ filename.cpp -o filename.out
clang++ filename.cpp -o filename.out
或者苹果的clang++
:
g++ filename.cpp -o filename.out
clang++ filename.cpp -o filename.out
您可以尝试使用
g++
:
g++ filename.cpp -o filename.out
clang++ filename.cpp -o filename.out
或者苹果的clang++
:
g++ filename.cpp -o filename.out
clang++ filename.cpp -o filename.out
您正在使用
gcc
编译C源代码
这就是问题所在,您应该改用
g++
。您正在使用gcc
编译C源代码
这就是问题所在,您应该改用g++