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.
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: