对已定义函数的未定义引用

undefined reference to function that is already defined

目前正在尝试在 Eclipse 中构建项目。项目浏览器如下图:

cabbie.c 中,我在下面的代码中得到错误 undefined reference to initialize...

#include <stdio.h>
#include <stdlib.h>
#include "../iotfclient.h"

Iotfclient client;
int rc;

int main() {
    /* Setup your example here, code that should run once
     */

    rc = initialize(&client, "h7dzt2", "Edison_cabquam", "notwindows95", "token", "Over_9000");

    /* Code in this loop will run repeatedly
     */
    for (;;) {

    }

    return 0;
}

该函数已在作为头文件包含的 iotfclient.h 中定义。定义为../iotfclient.h是否正确?我应该制作一个 Makefile 吗? iotfclient.h中的函数原型如下:

int initialize(Iotfclient *client, char *orgId, char *deviceType, char *deviceId, char *authmethod, char *authtoken);
/**
* Function used to initialize the IBM Watson IoT client using the config file which is generated when you register your device
* @param client - Reference to the Iotfclient
* @param configFilePath - File path to the configuration file 
*
* @return int return code
* error codes
* CONFIG_FILE_ERROR -3 - Config file not present or not in right format
*/

此项目正在尝试连接 bluemix 物联网平台。

函数initialize../iotfclient.h声明,它可能在../iotfclient.c定义 ],但是你编译这个文件并link它到你的项目吗?

initialize()iotfclient.h 声明为 。但是,没有必要定义。也就是说,编译器知道标识符initialise代表一个函数,但是要创建一个程序,你还得告诉链接器这个函数是如何工作的,也就是添加函数体。

尝试包括 ../iotfclient.c.