[英]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 IOT平台。
initialize()
在iotfclient.h
聲明 。 但是,沒有必要定義 。 換句話說,編譯器知道標識符initialise
代表函數,但是要創建程序,您還必須告訴鏈接程序函數的工作原理,即添加函數主體。
嘗試包含../iotfclient.c
。
函數initialize
在../iotfclient.h
聲明 ,它可能在../iotfclient.c
定義 ,但是您是否編譯了該文件並將其鏈接到您的項目?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.