Math.h problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Math.h problem

Post by fullerlee »

Hi,

I'm trying to use atan2, cos and sin.

I have the -lm flag set, and lib path seems to be pointing to the right place (there is a libm.a there).

At link time, I'm getting:
main.c:(.text+0x954): undefined reference to `atan2'
main.c:(.text+0x968): undefined reference to `cos'
main.c:(.text+0x99c): undefined reference to `sin'

I've searched, but haven't found a definitive answer beyond setting the -lm flag.
Can anyone help?
Thanks,
Lee

Makefile:

Code: Select all

TARGET = hello
OBJS = main.o pg.o

CFLAGS = -O2 -G0 -Wall -lm
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -lm
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = tactest

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)\lib\build.mak
Last edited by fullerlee on Mon Nov 14, 2005 11:09 am, edited 1 time in total.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Search on library link order, and begin-group, end-group.
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

Thanks, you pointed me in the right direction.

My makefile didn't have a LIBS section.

The fixed Makefile looks like this:

Code: Select all

TARGET = hello
OBJS = main.o pg.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = tactest

LIBS = -lm -lc

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)\lib\build.mak
Post Reply