Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linker error with LIBS=m before including common.mk #376

Open
briantilley opened this issue May 5, 2017 · 3 comments
Open

linker error with LIBS=m before including common.mk #376

briantilley opened this issue May 5, 2017 · 3 comments

Comments

@briantilley
Copy link

briantilley commented May 5, 2017

I need the sqrt() function from math.h, so I added #include <math.h> to my source and LIBS=m to my Makefile before include <path_to_esp-open-rtos>/common.mk.

compiler output:

CC /home/brian/Desktop/wifi-pwm/user_main.c
AR build/program.a
LD build/wifi-pwm.out
/opt/Espressif/esp-open-rtos/ld/program.ld:21: undefined symbol `malloc' referenced in expression
collect2: error: ld returned 1 exit status
/opt/Espressif/esp-open-rtos/common.mk:212: recipe for target 'build/wifi-pwm.out' failed
make: *** [build/wifi-pwm.out] Error 1

Makefile:

PROGRAM=wifi-pwm
PROGRAM_SRC_DIR=.
ESPBAUD=454800
EXTRA_COMPONENTS=extras/pwm extras/mbedtls extras/httpd
LIBS=m
EXTRA_CFLAGS=-DLWIP_HTTPD_CGI=1 -I./fsdata -mlongcalls -mtext-section-literals
include /opt/Espressif/esp-open-rtos/common.mk`

I have since rebuilt the entire toolchain from scratch, making sure to build esp-open-sdk with make toolchain esptool libhal STANDALONE=n as suggested by issue #79, and the problem persists. Are there any other libraries or flags I'm missing?

@Zaltora
Copy link
Contributor

Zaltora commented May 5, 2017

to include library math, i doing this in my project:
LIBS = hal gcc c m

@Zaltora
Copy link
Contributor

Zaltora commented May 5, 2017

In parameters.mk we found this:
LIBS ?= hal gcc c
if you write
LIBS=m,
it will replace LIBS variable

@briantilley
Copy link
Author

briantilley commented May 5, 2017

That did it, thank you! I've issued #377 to make it easier for future users. It seems to me there should be a way to simply add libraries per-project without concern for parameters.mk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants