【发布时间】:2020-08-17 11:13:20
【问题描述】:
我正在尝试使用以下方法从头文件中调用void process (uint8_t* I1,uint8_t* I2,float* D1,float* D2,const int32_t* dims);
int n=10;
size_t size=n*n*sizeof(uint8_t);
uint8_t* I1 = (uint8_t*)malloc(size);
uint8_t* I2 = (uint8_t*)malloc(size);
size=n*n*sizeof(float);
float* D1=(float*)malloc(size);
float* D2=(float*)malloc(size);
const int32_t dims[3] = {n,n,n};
process(I1,I2,D1,D2,dims);
但是当我在 linux 上使用 g++ 编译时,我收到消息 undefined reference to process(unsigned char*, unsigned char*, float*, float*, int const*)
为什么会这样?
【问题讨论】:
-
我在写C++,我想我之所以不认为我应该更多代码的原因是我一开始就不明白,为什么编译器无论如何都找不到函数过程它能做什么。在头文件的顶部有一些我认为值得一提的东西。 ` #ifndef _MSC_VER ` ` #include
` ` #else` ` typedef __int8 int8_t; ` #endif -
uint8_t可能只是unsigned char的类型别名。同样,int32_t对应于int。问题是您没有链接正确的目标文件/库。 -
undefined reference 是链接器问题,您必须 link 与适当的库。见what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix。
-
@Jarod42 是的,你是对的,谢谢
-
在 C++ 中使用
malloc几乎没有任何意义。
标签: c++ compilation g++ uint8t