对函数调用的未定义引用

undefined reference to a function call

我正在使用 cpp 在 Vivado HLS 中编写图像处理应用程序。我收到一个错误,说未定义引用 ISP(函数调用) 我已经多次看到这个错误并查看了类似的案例堆栈溢出并能够调试 previously.Mostly 之前的数据类型不匹配,但我现在似乎找不到当前版本的问题所在,我花了几个小时试图寻找它,思想一双全新的眼睛可以提供帮助,这也是我将其张贴在这里的原因。我已经在下面发布了代码的相关部分:

//header file
#include "hls_stream.h"
#include <ap_fixed.h>
//#include <ap_int.h>
#include "ap_int.h"
typedef ap_ufixed<24,24> bit_24;
typedef ap_fixed<11,8> fix;
typedef unsigned char uc;
typedef ap_uint<24> stream_width;
//typedef hls::stream<uc> Stream_t;

typedef hls::stream<stream_width> Stream_t;
struct configuration
{
    bool dn;
    bool ct;
    bool gm;
    bool tm;
};
struct pixel_f
{
    float r;
    float g;
    float b;
};

struct pixel_8
{
    uc r;
    uc g;
    uc b;
};
void ISP(Stream_t& in,Stream_t& out, float weights_ct[3][3],float ctrl_pts[3702][3],float weights[3702][3],float coefs[4][3],int num_ctrl_pts,float rev_tone[256][3], configuration config);

.

//testbench file(where the function is called)
float TsTw_tran[3][3];
float ctrl_pts[3702][3];
float coefs[4][3];
float weights[3702][3];
float rev_tone_s[256][3];
Mat img_rev = imread("C:/Users/20181217/Desktop/images/imgs/output_rev.png");
bit_24 pix_in;
    configuration config;
    config.ct = true;
    config.gm = true;
    config.tm = true;
    Stream_t in("in_tb");
    Stream_t out("out_tb");
    const int rows = 256;
    const int cols = 512;
    for(int i=0;i<256;i++)
    {
        for(int j=0; j<512;j++)
        {
            in << ((img_rev.at<Vec3b>(i, j)[2] << 16) | (img_rev.at<Vec3b>(i, j)[1] << 8) | (img_rev.at<Vec3b>(i, j)[0]));
        }
    }
    ISP(in,out,TsTw_tran,ctrl_pts,weights,coefs,num_ctrl_pts,rev_tone_s,config);

.

//core file(wher the function is defined)
void ISP(Stream_t& in,Stream_t& out, float TsTw_tran_rec[3][3],float ctrl_pts_rec[3702][3],float weights_rec[3702][3],float coefs_rec[4][3],float num_ctrl_pts, float rev_tone[256][3],configuration version)

我得到的错误是:undefined reference to ISP(hls::stream<ap_uint<24> >&, hls::stream<ap_uint<24> >&, float (*) [3], float (*) [3], float (*) [3], float (*) [3], int, float (*) [3], configuration)' collect2.exe: error: ld returned 1 exit status

任何 help/suggestions 将不胜感激,

提前致谢

在您的 header 中,此 ISP 函数的声明包含一个 int 参数:

int num_ctrl_pts

函数的实际定义中缺少此参数,或者它被定义为 float 而不是 int

C++ 允许重载函数,因此对于 C++ 编译器而言,这是其他一些完全不相关的函数,该问题最终会导致链接失败。

如果您想花几分钟时间检查编译器的错误消息,现在应该很明显,错误消息准确地告诉了您这个事实。在你的问题中,你在函数定义的正下方显示了编译器的错误消息,这使得这个错误很容易被发现。

链接阶段失败。查找具有此函数定义的库,然后将其添加到您的 makefile(或 cmake 文件)中。