在qt中MainWindow::on_pushButton_clicked();
如果我想从另一个 .c 文件调用该函数,我已添加 .c 和 .h 文件,并 #include 它。
但是编译仍然显示失败,它显示:
undefined reference to `Load_bmp(char const*, int*, int*, int*)
如何解决这个问题,谢谢。 这是我的代码: https://drive.google.com/file/d/0B6RzrpHF18PGd3UtWmEzdTQyLUk/view?usp=sharing
最佳答案
对于您的情况,最快的方法是将您的 bmp.c
文件重命名为 bmp.cpp
,它将神奇地构建。
另一种方法,必须使用,是更改接口(interface)以指定 c c 的链接项目文件,所以:
#ifndef _BMP_H_
#define _BMP_H_
#ifdef __cplusplus
extern "C" {
#endif
unsigned char* Load_bmp(const char *fname_s, int *Height, int *Width, int *Depth);
int Save_bmp_8bit(const char *fname_t, unsigned char *image_s, int height, int width);
int Save_bmp_24bit(const char *fname_t, unsigned char *image_s, int height, int width);
unsigned char * T8bitTo24bit(unsigned char *ima, size_t Height, size_t Width);
unsigned char * T24bitTo8bit(unsigned char *ima, size_t Height, size_t Width);
#ifdef __cplusplus
}
#endif
#endif
关于c++ - qt 中 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38180341/