-->
Page 1 of 3

Error "undefined reference to 'user_init'"

PostPosted: Sun May 03, 2015 1:02 pm
by Andrei Candale
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

Re: Error "undefined reference to 'user_init'"

PostPosted: Sun May 03, 2015 1:44 pm
by jcmvbkbc
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".

Re: Error "undefined reference to 'user_init'"

PostPosted: Sun May 03, 2015 1:51 pm
by Andrei Candale
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.

Re: Error "undefined reference to 'user_init'"

PostPosted: Sun May 03, 2015 1:54 pm
by jcmvbkbc
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?