GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
2017-08-27 22:48
1056 查看
在WINDOWS环境的CODE::BLOCKS里面写好的测试程序,想拿到Linux里面试验一把。报错: undefined reference to `std::ios_base::Init::Init()
1. 确认是否安装 gcc-c++的支持库
[root@ht168 ~]# rpm -qa| grep gcc
gcc-4.8.5-11.el7.x86_64
gcc-c++-4.8.5-11.el7.x86_64
libgcc-4.8.5-11.el7.x86_64
libgcc-4.8.5-11.el7.i686
2. 错误信息如下
[ecsmid@ht168 zhouc]$ gcc -m64 -o zhou while_test.cpp
/tmp/ccIp6o1B.o: In function `main':
while_test.cpp:(.text+0x2d): undefined reference to `std::cout'
while_test.cpp:(.text+0x32): 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*)'
while_test.cpp:(.text+0x3e): undefined reference to `std::cin'
while_test.cpp:(.text+0x43): undefined reference to `std::istream::operator>>(int&)'
while_test.cpp:(.text+0x58): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator void*() const'
while_test.cpp:(.text+0x6c): undefined reference to `std::cout'
while_test.cpp:(.text+0x71): 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*)'
while_test.cpp:(.text+0x7e): undefined reference to `std::ostream::operator<<(int)'
/tmp/ccIp6o1B.o: In function `__static_initialization_and_destruction_0(int, int)':
while_test.cpp:(.text+0xaa): undefined reference to `std::ios_base::Init::Init()'
while_test.cpp:(.text+0xb9): undefined reference to `std::ios_base::Init::~Init()'
3. 解决:
Linux下面采用gcc 编译 c++的代码第一需要安装gcc-c++支持库,其次编译的时候需要添加参数 -lstdc++。正确的编译方式如下
[ecsmid@ht168 zhouc]$ gcc -m64 -lstdc++ -Wall -o zhou while_test.cpp
[ecsmid@ht168 zhouc]$
1. 确认是否安装 gcc-c++的支持库
[root@ht168 ~]# rpm -qa| grep gcc
gcc-4.8.5-11.el7.x86_64
gcc-c++-4.8.5-11.el7.x86_64
libgcc-4.8.5-11.el7.x86_64
libgcc-4.8.5-11.el7.i686
2. 错误信息如下
[ecsmid@ht168 zhouc]$ gcc -m64 -o zhou while_test.cpp
/tmp/ccIp6o1B.o: In function `main':
while_test.cpp:(.text+0x2d): undefined reference to `std::cout'
while_test.cpp:(.text+0x32): 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*)'
while_test.cpp:(.text+0x3e): undefined reference to `std::cin'
while_test.cpp:(.text+0x43): undefined reference to `std::istream::operator>>(int&)'
while_test.cpp:(.text+0x58): undefined reference to `std::basic_ios<char, std::char_traits<char> >::operator void*() const'
while_test.cpp:(.text+0x6c): undefined reference to `std::cout'
while_test.cpp:(.text+0x71): 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*)'
while_test.cpp:(.text+0x7e): undefined reference to `std::ostream::operator<<(int)'
/tmp/ccIp6o1B.o: In function `__static_initialization_and_destruction_0(int, int)':
while_test.cpp:(.text+0xaa): undefined reference to `std::ios_base::Init::Init()'
while_test.cpp:(.text+0xb9): undefined reference to `std::ios_base::Init::~Init()'
3. 解决:
Linux下面采用gcc 编译 c++的代码第一需要安装gcc-c++支持库,其次编译的时候需要添加参数 -lstdc++。正确的编译方式如下
[ecsmid@ht168 zhouc]$ gcc -m64 -lstdc++ -Wall -o zhou while_test.cpp
[ecsmid@ht168 zhouc]$
相关文章推荐
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题——gcc编译C++代码
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- NDK 编译时出现 algorithm,vector std::ios_base::Init::Init() , 以及ostream等问题解决方案
- undefined reference to `std::ios_base::Init::Init() 解决
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题
- gcc编译出现 undefined reference to 的问题
- gcc编译出现undefined reference to 的问题
- ffmpeg libx264编译出现error: undefined reference to 'x264_picture_init'等问题的解决方法
- undefined reference to `std::ios_base::Init::Init()
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- undefined reference to `std::ios_base::Init::Init()
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- 解决DEV C++编译时出现的“ undefined reference to `___dyn_tls_init_callback'...”问题
- gcc编译线程程序需带-lpthread选项(否则出错:undefined reference to `pthread_create')
- gcc 引用math.h头文件,编译出现undefined reference to `pow‘等错
- ios 编译过程中碰到std::ios_base::Init::~Init()错误的问题解决方法