Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Andrei Candale
#16371 Hi all.

I've been trying for some time now to compile a simple program with espressif sdk.
The error I get is the following:
Code: Select allLD build/app.out
/home/andrei/workspace/licenta/toolchain/espressif_sdk/esp8266/esp-open-sdk/sdk/lib/libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x3e4): undefined reference to `user_init'
/home/andrei/workspace/licenta/toolchain/espressif_sdk/esp8266/esp-open-sdk/sdk/lib/libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x57e): undefined reference to `user_init'
collect2: error: ld returned 1 exit status
make: *** [build/app.out] Error 1


This is my code:
Code: Select all#include "ets_sys.h"
#include "osapi.h"

void user_init() {
    os_printf("SDK version: %s\n", system_get_sdk_versionn());
}


Some help would be greatly appreciated.
Thank you
User avatar
By jcmvbkbc
#16376
Andrei Candale wrote:This is my code:
Code: Select all#include "ets_sys.h"
#include "osapi.h"

void user_init() {
    os_printf("SDK version: %s\n", system_get_sdk_versionn());
}


Looks like you've put it into cpp file. Either move it to c (not cpp) file, or declare it as extern "C".
User avatar
By Andrei Candale
#16379
jcmvbkbc wrote:
Andrei Candale wrote:This is my code:
Code: Select all#include "ets_sys.h"
#include "osapi.h"

void user_init() {
    os_printf("SDK version: %s\n", system_get_sdk_versionn());
}


Looks like you've put it into cpp file. Either move it to c (not cpp) file, or declare it as extern "C".


It is in .c file. Tried with .cpp and extern "C" but it still won't work.
User avatar
By jcmvbkbc
#16381
Andrei Candale wrote:
jcmvbkbc wrote:Looks like you've put it into cpp file. Either move it to c (not cpp) file, or declare it as extern "C".

It is in .c file. Tried with .cpp and extern "C" but it still won't work.

Ok, is that file compiled at all?
Can you add V=1 to your make command and share the full build log?