我有libstdc++6-dev,但仍然有stl链接错误
I have libstdc++6-dev but still have stl linked error
我的 gcc 版本是 4.7
这是我的简单源代码:我安装了libstdc++6-dev,我认为它应该包括stl
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
using namespace std;
int main()
{
Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) };
Point_2 result[5];
Point_2 *ptr = CGAL::convex_hull_2( points, points+5, result );
std::cout << ptr - result << " points on the convex hull" << std::endl;
return 0;
}
我的编译命令是:
gcc -c hello.cpp -o hello.o
gcc -o hello hello.o 1>info.txt 2>error.txt
错误是:
hello.o: In function `main':
hello.cpp:(.text+0x156): undefined reference to `std::cout'
hello.cpp:(.text+0x15b): undefined reference to `std::ostream::operator<<(long)'
hello.cpp:(.text+0x168): 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*)'
....
似乎 stl 库仍然不起作用,但我安装了 libstdc++6-dev,为什么它仍然这样发生?
正如克里斯所说gcc
不适合C++。您可以使用两种不同的方法解决问题
gcc -c hello.cpp -o hello.o
gcc -lstdc++ -o hello hello.o 1>info.txt 2>error.txt
或
g++ -c hello.cpp -o hello.o
g++ -o hello hello.o 1>info.txt 2>error.txt
相关文章:
- 如何在 android ndk 上链接 C 和 C++ 代码,以及 C 和 C++ 运行时库(包括 STL)?
- Visual Studio 2017 无法检查静态链接库中对象中的 STL 容器
- xcode 上的 stl 链接错误
- 链接模板与传递 stl 容器的问题
- 释放包含STL类的链接列表结构的内存
- RIOS X Mavericks上使用clang++构建的内部示例在链接上找不到STL标准库
- 如果我尝试在同一项目中使用 stl 矢量和 CUDA 推力矢量,为什么会出现链接错误
- 没有运行库的c++链接stl
- STL链接列表问题
- 如何调试STL/C++的GCC/LD链接过程
- 当我使用 STL 在 Linux 上编译 C++ 程序时,STL 库是如何链接的
- 我有libstdc++6-dev,但仍然有stl链接错误
- NDK使用STL时发生运行时链接错误
- 有没有办法仅将静态与 STL 链接
- 初始化哈希表的 stl 列表动态数组(单独链接)
- 使用stl映射时出现链接器错误
- 使用STL容器时出现链接错误
- STL链接表示多项式
- c++: STL链接+=复制节点
- CodeComposerStudio的STL链接错误