C++ libnoise 错误到佩林
c++ libnoise error to Perlin
我在Windows上安装了带有代码::blocks的libnoise。
在编译时,它会给出一个错误:
undefined reference to `noise::module::Perlin::Perlin()'
undefined reference to `noise::module::Perlin::GetValue(double, double, double) const'
undefined reference to `vtable for noise::module::Perlin'
undefined reference to `noise::module::Module::~Module()'
但引用在perlin.h
头文件中
如何解决此问题?
在Windows上,libnoise带有一个*.def文件,用于导出符号。但是当我今天早上尝试以 64 位编译库时,似乎这种机制不起作用。我不得不"手动"导出类符号:
导出 libnoise 符号的步骤:
.定义预处理器变量 LIBNOISE_EXPORT
将 lib 编译为共享库时,编译使用 lib 的项目时不要添加它
.在 lib 的顶级标头中添加一些导出宏(例如 basictypes.h):
#if defined(WIN32)
# ifdef LIBNOISE_EXPORT
# define LIBNOISE_DLL __declspec(dllexport)
# else
# define LIBNOISE_DLL __declspec(dllimport)
# endif
#else
# define LIBNOISE_DLL
#endif
.在类定义前面添加LIBNOISE_DLL宏:
class LIBNOISE_DLL Perlin: public Module
{
...
这对我来说是诀窍
注意:如果您尝试此解决方案,请不要在编译过程中使用 *.def 文件
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ libnoise 错误到佩林
- Linux C++, libnoise, getvalue() 返回值 > 1?(报告为错误)