gpt4 book ai didi

c - 包括类型定义,但不包括函数

转载 作者:行者123 更新时间:2023-11-30 14:27:02 25 4
gpt4 key购买 nike

我正在编写一些使用 MATLAB 提供的 C 库的代码(从 *.mat 文件中提取数据)。在我的 IDE (Code::Blocks) 中,我包含了包含必要的“mat.h”的文件夹,该文件夹位于网络驱动器上。当我这样做时,我的代码可以识别 mat.h 中定义的类型,但是每当我从文件中调用函数时,我都会收到“ undefined reference ”错误。 MathWorks 提供的示例代码也是如此。通常是什么类型的问题导致这种情况?

#include "mat.h"
int main (void) {
MATFile *pmat; // Compiles only when compiler is told to search in mat.h directory
pmat = matOpen("example_filename", "r"); // Never compiles
return 0;
}

谢谢!卡梅伦

最佳答案

“ undefined reference ”通常是链接器错误。不是头文件的问题。您需要告诉链接器将 MATLAB 的库(或专用对象)链接到您的程序。

不知道这是如何在 Code::Blocks 中完成的。在 Code:Blocks 文档中描述了 here .

关于c - 包括类型定义,但不包括函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8233543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com