【发布时间】:2016-02-03 17:26:07
【问题描述】:
我正在从我用 Cpp 编写的 Qt 编写的头文件中调用 C 函数。当我尝试编译我的 Qt 应用程序时,我不断收到链接错误。
这是头文件:
#ifndef GROUND_SERVER_H
#define GROUND_SERVER_H
#ifdef __cplusplus
extern "C" {
#endif
struct system_info{
char id[33];
};
/* Support function for the below function */
void Generate_Key(char*,char*,char*);
/* Runs the actual key generation as well as
moves the file to the respectful card or
USB drive inserted in the system that will
act as the user system key */
void run_key_generation(struct system_info*,char*,char*);
/* Function to run the server on a selected
port at which the medium that the server
is to listen on will be connected. */
void run_server(unsigned short);
void generate_id();
#ifdef __cplusplus
};
#endif
#endif
【问题讨论】:
-
现在我只是将标题包含在我的 Qt 项目中,然后尝试调用 generate_id() 函数..
-
到底是什么错误?
-
架构 x86_64 的未定义符号:“_generate_id”,引用自:mainwindow.o ld 中的 MainWindow::MainWindow(QWidget*):未找到架构 x86_64 clang 的符号:错误:链接器命令退出代码 1 失败(使用 -v 查看调用) make: *** [Ground_Control.app/Contents/MacOS/Ground_Control] 错误 1 12:32:46: 进程“/usr/bin/make”退出代码2. 构建/部署项目 Ground_Control (kit: Desktop Qt 5.3 clang 64bit) 时出错当执行步骤“Make”@AdiLevin
-
Eh ... 是否您链接到包含这些函数定义的目标文件(或库)?
-
@JakeBrown 您还需要使用函数定义(可能是
Ground_Server.c)编译文件,这将产生一个您需要添加到链接的目标文件(例如Ground_Server.o)构建阶段。