- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am using DE1-SoC. I have a C code which uses pow and sqrt from math.h library. But when i try to make file is shows this error, and says:
undefined reference to 'pow'
undefined reference to 'sqrt'
here is the make file content:
#
TARGET = prognostic2
#
ALT_DEVICE_FAMILY ?= soc_cv_av
SOCEDS_ROOT ?= $(SOCEDS_DEST_ROOT)
HWLIBS_ROOT = $(SOCEDS_ROOT)/ip/altera/hps/altera_hps/hwlib
CROSS_COMPILE = arm-linux-gnueabihf-
CFLAGS = -g -Wall -D$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/
LDFLAGS = -g -Wall
CC = $(CROSS_COMPILE)gcc
ARCH= arm
build: $(TARGET)
$(TARGET): commandOne.o
$(CC) $(LDFLAGS) $^ -o $@
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -f $(TARGET) *.a *.o *~
I found that this problem can be solve by inserting -lm in to the command such as:
gcc main.c -o main -lm
But I am not sure how the make file work, which part should I add to solve this problem? I have tried put a few places in the file but seems not working.
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am unfamiliar with error you are seeing, this seems to be an uncommon issue,
Have you try some check up on the issue on Stackoverflow support? There are a lot of possibilities regarding the errors you are seeing, here are some I could find related to yours:
https://stackoverflow.com/questions/12824134/undefined-reference-to-pow-in-c-despite-including-math-h
https://stackoverflow.com/questions/27475977/c-undefined-reference-to-sqrt-even-with-lm

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page