如何将我的C++程序与newmat类链接
How can I link my C++ program with the newmat class?
我下载了newmat包,我在程序中包含了"include.h"answers"newmat.h"标头,但它无法识别名称空间newmat;如果我定义NEWMAT名称空间,甚至删除整行,我会得到几个错误,比如:
undefined reference to `BaseMatrix::t() const'
似乎没有指向该库的链接,我在谷歌上搜索了解决方案,有些人会说我已经从neewmat包中查找了.o或.a库文件,并将它们复制到lib文件夹中,其他人说我应该使用:gcc myprogram.c thebrary.o链接到库,但我在newmat包中找不到任何类型为.o或.a的文件,而且dev-c++编译器也不认为使用gcc有什么特别之处。
我是一个初学者,如果有人能帮我在程序上实现这个包,我将不胜感激。
下面是一个在Debian/Ubuuntu:中使用libnewmat10 dev包的例子
edd@max:~$ cd /tmp
edd@max:/tmp$ zcat /usr/share/doc/libnewmat10-dev/examples/example.cpp.gz > ex.cpp
edd@max:/tmp$ g++ ex.cpp -o ex -I/usr/include/newmat -lnewmat
edd@max:/tmp$ ./ex | head -25
Demonstration of Matrix package
Print a real number (may help lost memory test): 3.14159
Test 1 - traditional, bad
Estimates and their standard errors
1.39166 0.53188
1.98310 0.20932
0.95221 0.27731
Observations, fitted value, residual value, hat value
2.400 1.700 8.300 7.770 0.530 0.280
1.800 0.900 5.500 5.818 -0.318 0.190
2.400 1.600 8.000 7.675 0.325 0.229
3.000 1.900 8.500 9.150 -0.650 0.446
2.000 0.500 5.700 5.834 -0.134 0.271
1.200 0.600 4.400 4.343 0.057 0.480
2.000 1.100 6.300 6.405 -0.105 0.143
2.700 1.000 7.900 7.698 0.202 0.153
3.600 0.500 9.100 9.007 0.093 0.808
edd@max:/tmp$
有关更多信息,请参阅Robert的其余文档。从20多年前开始,我就经常使用newmat。但现在,我更喜欢康拉德·桑德森的《Armadillo》。
您需要查阅您的想法文档,了解如何更改链接命令或使用Makefile
。
相关文章:
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- CMake-按正确顺序将项目与C运行时对象文件链接
- 从链接列表c++中删除一个项目
- 有根的二进制搜索树.保留与其父级的链接
- 读取文件的最后一行并输入到链接列表时出错
- 静态数据成员的问题-修复链接错误会导致编译器错误
- node-gyp 在 macOS 上未正确链接库
- 基于boost的程序的静态链接——zlib问题
- 无法链接 CMake 中的本地库
- 内联函数中具有内部链接的全局变量
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 使用gcc从静态链接的文件中查找可选符号
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 下面是我为检测链接列表中的循环而制作的代码
- 有了gcc,是否可以链接库,但前提是它存在
- 使用C链接在函数内部创建C++模板
- Visual Studio mkl_link_tool.exe链接错误
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- 如何将我的C++程序与newmat类链接