c++ - qt 中 undefined reference

标签 c++ c qt

在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

最佳答案

因此使用 cpp 扩展文件。

对于您的情况,最快的方法是将您的 bmp.c 文件重命名为 bmp.cpp,它将神奇地构建。

另一种方法,必须使用,是更改接口(interface)以指定 的链接项目文件,所以:

#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/

相关文章:

提示 FILE * 未初始化

C sockaddr函数调用sendto?

c - 无需 root 即可将 Web 服务器绑定(bind)到端口 80

qt - 如何在 MainWindow 以外的其他类中创建和调用插槽?

c++ - gluPickMatrix - 出了点问题,一个对象总是在现场

c++ - 具有方法重载的接口(interface)类?

c++ - 嵌套类成员函数不能访问封闭类的函数。为什么?

c++拆分函数随机崩溃

c++ - 如何使 operator[] 返回对 unsigned int 中各个位的引用?

c++ - 如何在 MacOS X Sierra 上安装 Qt 并在终端上添加 qmake