-->
Page 1 of 2

Not able to use functions from user_interface.h

PostPosted: Sat Jul 02, 2016 2:45 pm
by debojitk
Hi,
I am using eclipse Arduino ide for development of esp projects. Everything works fine but when I add any method from user_interface.h, for example wifi_station_set_hostname(char *), it gives me a strange error stating "undefined reference" of wifi_station_set_hostname method. Somewhere in this forum I found that the following construct would resolve the problem:
Code: Select allextern "C"{
 #include "user_interface.h"
}

This thing works well in Arduino ide, but with eclipse arduino ide setup I still get the same error.
Strangely when I add a method in one of my custom classes and there if I put wifi_station_set_hostname inside that function along with the extern-include setup, it works.
Could anyone put some light here.
The specific error starts at combiner:
Code: Select all'Finished building: C:/Users/DK/Arduino/libraries/RadioControllerESP/RadioControllerESP.cpp'
' '
'Starting combiner'
"G:\debojit\electronics project\2016\ide\eclipseArduino\arduinoPlugin\tools\esp8266\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -g -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-LG:/debojit/electronics project/2016/ide/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/lib" "-LG:/debojit/electronics project/2016/ide/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/ld" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy  -o "G:/debojit/electronics project/2016/ide/eclipseArduino/workspace/ESPServer/Release/ESPServer.elf" -Wl,--start-group    ./.ino.cpp.o  ./libraries/SPI/SPI.cpp.o  ./libraries/RadioControllerESP/GenericList.cpp.o ./libraries/RadioControllerESP/RadioControllerESP.cpp.o  ./libraries/RF24Network/RF24Network.cpp.o ./libraries/RF24Network/Sync.cpp.o  ./libraries/RF24Mesh/RF24Mesh.cpp.o  ./libraries/RF24/RF24.cpp.o  ./libraries/ESP8266mDNS/ESP8266mDNS.cpp.o  ./libraries/ESP8266WiFi/src/ESP8266WiFi.cpp.o ./libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp.o ./libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp.o ./libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp.o ./libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp.o ./libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp.o ./libraries/ESP8266WiFi/src/WiFiClient.cpp.o ./libraries/ESP8266WiFi/src/WiFiClientSecure.cpp.o ./libraries/ESP8266WiFi/src/WiFiServer.cpp.o ./libraries/ESP8266WiFi/src/WiFiUdp.cpp.o  ./libraries/ESP8266WebServer/src/ESP8266WebServer.cpp.o ./libraries/ESP8266WebServer/src/Parsing.cpp.o   arduino.ar   "G:/debojit/electronics project/2016/ide/eclipseArduino/workspace/ESPServer/Release/arduino.ar" -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -llwip -Wl,--end-group  "-LG:/debojit/electronics project/2016/ide/eclipseArduino/workspace/ESPServer/Release"
./.ino.cpp.o: In function `requestHandler()':
G:\debojit\electronics project\2016\ide\eclipseArduino\workspace\ESPServer\Release/../WiFiAccessPoint.ino:126: undefined reference to `wifi_station_set_hostname(char*)'
./.ino.cpp.o: In function `String::operator!=(char const*) const':
G:\debojit\electronics project\2016\ide\eclipseArduino\arduinoPlugin\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266/WString.h:190: undefined reference to `wifi_station_set_hostname(char*)'
collect2.exe: error: ld returned 1 exit status
makefile:93: recipe for target 'ESPServer.elf' failed
make: *** [ESPServer.elf] Error 1

Re: Not able to use functions from user_interface.h

PostPosted: Wed Oct 05, 2016 10:39 am
by lsk123
I have the same problem with the new 3.1 plugin. As a test, I tried building TestEspApi in examples. Here is the error:

'Starting combiner'
"D:\Utils\eclipseArduino3.1.sloeber\arduinoPlugin\tools\esp8266\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -g -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-LD:/Utils/eclipseArduino3.1.sloeber/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/lib" "-LD:/Utils/eclipseArduino3.1.sloeber/arduinoPlugin/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/ld" "-Teagle.flash.4m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -o "D:/Utils/eclipseArduino3.1.sloeber/workspace/test1/Release/test1.elf" -Wl,--start-group -L"D:/D_TEMP/lib" -lmain .\.ino.cpp.o arduino.ar "D:/Utils/eclipseArduino3.1.sloeber/workspace/test1/Release/arduino.ar" -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -llwip_gcc -lstdc++ -Wl,--end-group "-LD:/Utils/eclipseArduino3.1.sloeber/workspace/test1/Release" -L"D:/D_TEMP/lib"
.\.ino.cpp.o: In function `print_softap_config(Stream&, softap_config const&)':
D:\Utils\eclipseArduino3.1.sloeber\workspace\test1\Release/../TestEspApi.ino:175: undefined reference to `system_get_rst_info()'
D:\Utils\eclipseArduino3.1.sloeber\workspace\test1\Release/../TestEspApi.ino:175: undefined reference to `system_get_free_heap_size()'


Any suggestions on how to get around this?


Thanks!

Re: Not able to use functions from user_interface.h

PostPosted: Thu Oct 06, 2016 9:19 am
by martinayotte
When you included user_interface.h, you need to include it a plain "C" :
Code: Select allextern "C" {
  #include "user_interface.h"
}

Re: Not able to use functions from user_interface.h

PostPosted: Thu Oct 06, 2016 10:24 am
by lsk123
Yes, I have that defined, thanks. It's the linker that is complaining. I found the functions in the libmain.a but they are not being picked up for some reason:

nm D:\Utils\eclipseArduino3.1.sloeber\arduinoPlugin\packages\esp8266\hardware\esp8266\2.3.0\tools\sdk\lib\libmain.a | grep system_get_free_heap_size
00000d54 T system_get_free_heap_size

Any other ideas?