ubuntu 下运行程序报错 对‘std::cout’未定义的引用

2023-05-16

我今天就遇到了,果然换为g++就好了。

下面转载自:https://blog.csdn.net/nicolaskaiqi/article/details/52814087?_t=t

ubuntu 下运行程序报错 对‘std::cout’未定义的引用
NicolasKaiqi 2016-10-14 10:57:26 12708 已收藏 4
分类专栏: ubuntu 文章标签: c++
版权
ubuntu
专栏收录该内容
5 篇文章 0 订阅
订阅专栏

在编译c++程序时运行gcc -o fileio fileio.cpp报错,错误提示为:

/tmp/ccinWfZ2.o:在函数‘main’中:
fileio.cpp:(.text+0x26):对‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()’未定义的引用
fileio.cpp:(.text+0x30):对‘std::cout’未定义的引用
fileio.cpp:(.text+0x35):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0x44):对‘std::cin’未定义的引用
fileio.cpp:(.text+0x49):对‘std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’未定义的引用
fileio.cpp:(.text+0x69):对‘std::string::c_str() const’未定义的引用
fileio.cpp:(.text+0x80):对‘std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(char const*, std::_Ios_Openmode)’未定义的引用
fileio.cpp:(.text+0x94):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0x9e):对‘std::cout’未定义的引用
fileio.cpp:(.text+0xa3):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0xb2):对‘std::cin’未定义的引用
fileio.cpp:(.text+0xb7):对‘std::istream::operator>>(float&)’未定义的引用
fileio.cpp:(.text+0xd1):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0xe7):对‘std::ostream::operator<<(float)’未定义的引用
fileio.cpp:(.text+0xec):对‘std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)’未定义的引用
fileio.cpp:(.text+0xf4):对‘std::ostream::operator<<(std::ostream& (*)(std::ostream&))’未定义的引用
fileio.cpp:(.text+0x103):对‘std::basic_ofstream<char, std::char_traits<char> >::close()’未定义的引用
fileio.cpp:(.text+0x112):对‘std::string::c_str() const’未定义的引用
fileio.cpp:(.text+0x12c):对‘std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)’未定义的引用
fileio.cpp:(.text+0x136):对‘std::cout’未定义的引用
fileio.cpp:(.text+0x13b):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0x14d):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
fileio.cpp:(.text+0x15a):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0x16d):对‘std::cout’未定义的引用
fileio.cpp:(.text+0x172):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)’未定义的引用
fileio.cpp:(.text+0x18b):对‘std::istream::get(char&)’未定义的引用
fileio.cpp:(.text+0x1a0):对‘std::basic_ios<char, std::char_traits<char> >::operator void*() const’未定义的引用
fileio.cpp:(.text+0x1b4):对‘std::cout’未定义的引用
fileio.cpp:(.text+0x1b9):对‘std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’未定义的引用
fileio.cpp:(.text+0x1c8):对‘std::basic_ifstream<char, std::char_traits<char> >::close()’未定义的引用
fileio.cpp:(.text+0x1dc):对‘std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()’未定义的引用
fileio.cpp:(.text+0x1eb):对‘std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()’未定义的引用
fileio.cpp:(.text+0x1fa):对‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()’未定义的引用
fileio.cpp:(.text+0x21f):对‘std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()’未定义的引用
fileio.cpp:(.text+0x233):对‘std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()’未定义的引用
fileio.cpp:(.text+0x247):对‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()’未定义的引用
/tmp/ccinWfZ2.o:在函数‘__static_initialization_and_destruction_0(int, int)’中:
fileio.cpp:(.text+0x288):对‘std::ios_base::Init::Init()’未定义的引用
fileio.cpp:(.text+0x297):对‘std::ios_base::Init::~Init()’未定义的引用
/tmp/ccinWfZ2.o:(.eh_frame+0x4b):对‘__gxx_personality_v0’未定义的引用
collect2: error: ld returned 1 exit status
nicolas@bestpc:~/tmp$ gcc -o cryptoDemo cryptoDemo.cpp
/tmp/ccRtQPe6.o:在函数‘testAes(char*, int, char*, int)’中:
cryptoDemo.cpp:(.text+0xfb):对‘AES_set_encrypt_key’未定义的引用
cryptoDemo.cpp:(.text+0x193):对‘AES_encrypt’未定义的引用
cryptoDemo.cpp:(.text+0x293):对‘AES_encrypt’未定义的引用
cryptoDemo.cpp:(.text+0x317):对‘AES_set_decrypt_key’未定义的引用
cryptoDemo.cpp:(.text+0x3a9):对‘AES_decrypt’未定义的引用
cryptoDemo.cpp:(.text+0x49e):对‘AES_decrypt’未定义的引用
collect2: error: ld returned 1 exit status

不要被这么长的错误吓到了,其实很简单,你只是用错了编译器而已!

把gcc改为g++即可!
 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ubuntu 下运行程序报错 对‘std::cout’未定义的引用 的相关文章

随机推荐