欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

undefined reference to `SetPduPowerConsumptionCnt'錯(cuò)誤的解決方法

 更新時(shí)間:2013年07月26日 09:30:51   作者:  
編譯時(shí)出現(xiàn)undefined reference to `SetPduPowerConsumptionCnt'錯(cuò)誤要如何解決呢?有沒(méi)有什么好的解決方法?下面小編就為大家解答吧,如果你也遇到了這種情況,可以過(guò)來(lái)參考下

問(wèn)題:
程序模型用C++語(yǔ)言編寫(xiě),在程序模型和調(diào)用函數(shù)之間添加了一個(gè)接口文件modelc.cpp,用來(lái)讓用c語(yǔ)言程序調(diào)用程序模型中的函數(shù);

新添加了兩個(gè)函數(shù)setPduPowerConsumptionCnt()和setPduPowerConsumptionTot(),用來(lái)清除PDU模型中的總功耗和功耗計(jì)數(shù)器;

編譯時(shí)出現(xiàn)錯(cuò)誤提示:

復(fù)制代碼 代碼如下:

dingq@wd-u1110:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket$ make clean;make
rm -f *.o pdu
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c main.cpp -o main.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c model.cpp -o model.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c modelc.cpp -o modelc.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c IniFile.cpp -o IniFile.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c ClientSocket.cpp -o ClientSocket.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c Thread.cpp -o Thread.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c SensorReader.cpp -o SensorReader.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c LcdWriter.cpp -o LcdWriter.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c Monitor.cpp -o Monitor.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c Helper.cpp -o Helper.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c Mutex.cpp -o Mutex.o
arm-linux-g++ -g3 -Wall -o0 -I../../../tools/eldk42/arm/usr/include/ -I../../../tools/eldk42/arm/usr/include/C++/4.2.2/ -c serial.cpp -o serial.o
arm-linux-gcc -g3 -Wall -o0 -c frm_package.c -o frm_package.o
arm-linux-gcc -g3 -Wall -o0 -c nettrans.c -o nettrans.o
arm-linux-gcc -g3 -Wall -o0 -c sensor-att7053.c -o sensor-att7053.o
arm-linux-g++ -L../../../tools/lib/ -lpthread -o pdu main.o model.o modelc.o IniFile.o ClientSocket.o Thread.o SensorReader.o LcdWriter.o Monitor.o Helper.o Mutex.o serial.o frm_package.o nettrans.o sensor-att7053.o
sensor-att7053.o: In function `reset_EnergyPort':
/home/dingq/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/sensor-att7053.c:83: undefined reference to `SetPduPowerConsumptionCnt'
/home/dingq/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/sensor-att7053.c:92: undefined reference to `SetPduPowerConsumptionTot'
collect2: ld returned 1 exit status
make: *** [pdu] Error 1

解決辦法:
1. 忘了在modelc.cpp的函數(shù)實(shí)現(xiàn)中添加extern "C"了。
復(fù)制代碼 代碼如下:

extern "C" int setPduPowerConsumptionCnt(int index, unsigned int val) {
 if (index > 8 || index < 1) {
  printf("Error: The index available is between 1 and 8.\n");
  return -1;
 }
 model->Channels()[index-1].TheEnergyPort().SetPowerConsumptionCount(val);

 return 0;
}


添加之后,再次編譯,錯(cuò)誤仍然存在。
查找了半天,原來(lái)頭文件modelc.h中和實(shí)現(xiàn)文件modelc.cpp中的函數(shù)名差了一個(gè)符號(hào),頭文件中是小寫(xiě)的s,setPduPowerConsumptionCnt,而實(shí)現(xiàn)文件中用了大寫(xiě)的S,SetPduPowerConsumptionCnt;而使用vim編輯器時(shí),沒(méi)有設(shè)定區(qū)分大小寫(xiě),導(dǎo)致沒(méi)有很容易一眼看出來(lái)。

修改之后,成功編譯。
問(wèn)題解決。

相關(guān)文章

  • C++中main函數(shù)怎樣調(diào)用類內(nèi)函數(shù)

    C++中main函數(shù)怎樣調(diào)用類內(nèi)函數(shù)

    這篇文章主要介紹了C++中main函數(shù)怎樣調(diào)用類內(nèi)函數(shù)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • C++中int類型按字節(jié)打印輸出的方法

    C++中int類型按字節(jié)打印輸出的方法

    這篇文章主要給大家介紹了關(guān)于C++中int類型按字節(jié)打印輸出的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用C++具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • C語(yǔ)言操作符超詳細(xì)講解上篇

    C語(yǔ)言操作符超詳細(xì)講解上篇

    C?語(yǔ)言提供了豐富的操作符,有:算術(shù)操作符,移位操作符,位操作符,賦值操作符,單目操作符,關(guān)系操作符,邏輯操作符,條件操作符等。因?yàn)槠^(guò)大將分兩篇講解,讓我們通讀本篇來(lái)詳細(xì)了解吧
    2022-04-04
  • C語(yǔ)言分支循環(huán)其嵌套語(yǔ)句的使用

    C語(yǔ)言分支循環(huán)其嵌套語(yǔ)句的使用

    本文主要介紹了switch 嵌套和循環(huán)嵌套,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • C++ 詳解數(shù)據(jù)結(jié)構(gòu)中的搜索二叉樹(shù)

    C++ 詳解數(shù)據(jù)結(jié)構(gòu)中的搜索二叉樹(shù)

    搜索二叉樹(shù)是一種具有良好排序和查找性能的二叉樹(shù)數(shù)據(jù)結(jié)構(gòu),包括多種操作,本篇只介紹插入,排序(遍歷),和刪除操作,重點(diǎn)是刪除操作比較復(fù)雜
    2022-04-04
  • 基于Windows API分解路徑問(wèn)題的詳解

    基于Windows API分解路徑問(wèn)題的詳解

    本篇文章是對(duì)Windows API分解路徑進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • 常用的STL查找算法

    常用的STL查找算法

    這篇文章主要介紹了常用的STL查找算法的相關(guān)資料,十分的詳細(xì),需要的朋友可以參考下
    2015-07-07
  • C語(yǔ)言雙指針多方法旋轉(zhuǎn)數(shù)組解題LeetCode

    C語(yǔ)言雙指針多方法旋轉(zhuǎn)數(shù)組解題LeetCode

    這篇文章主要為大家介紹了C語(yǔ)言雙指針使用多方法旋轉(zhuǎn)數(shù)組題解LeetCode,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2022-02-02
  • C語(yǔ)言實(shí)現(xiàn)銷售管理系統(tǒng)

    C語(yǔ)言實(shí)現(xiàn)銷售管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)銷售管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • CString,字符串,整數(shù)等相互轉(zhuǎn)換方法(推薦)

    CString,字符串,整數(shù)等相互轉(zhuǎn)換方法(推薦)

    下面小編就為大家?guī)?lái)一篇CString,字符串,整數(shù)等相互轉(zhuǎn)換方法(推薦)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-09-09

最新評(píng)論