ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1

Tina ·
更新时间:2024-11-11
· 807 次阅读

今天编写一个简单的代码,报错了:

template class matrix final { public: matrix(uint32_t size): SIZE(size) { _data = static_cast(malloc(SIZE * sizeof(T*))); for (uint32_t i = 0; i < SIZE; ++i) { _data[i] = new T[SIZE]; } } inline const uint32_t size() const { return SIZE; } T* operator[](uint32_t index) const { return _data[index]; } ~matrix() { for (uint32_t i = 0; i < SIZE; ++i) { delete[] _data[i]; } free(_data); } private: const uint32_t SIZE; T** _data; };

改为编译语句为:

:gcc -lstdc++ -std=c++11 main.cc -o main

解决了。


作者:LU_ZHAO



x86_64 symbol found x8 ld NOT for with exit clang error

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章