math.h在64位Ubuntu12.04下编译LinSched 3.3时引用失败

时间:2013-02-06 15:58:25

标签: linux compiler-errors 64-bit ubuntu-12.04

在64位Ubuntu-12.04下编译LinSched 3.3会引发以下错误:

******/home/xxxxx/Desktop/linsched_3.3/tools/linsched/tests/linsched_rand_test.c:169: undefined reference to `sqrt'
collect2: ld returned 1 exit status
make[1]: [linsched_rand_test] Error 1
make[1]: Leaving directory `/home/jianguo/Desktop/linsched_3.3/tools/linsched/tests'
make: [all] Error 2*

在引用/链接到math.h时似乎存在问题,即: 数学:/usr/include/math.h

从LinSched 3.3的make文件中,CFLAGS和LFLAGS定义如下,

    CC = ${CROSS_COMPILE}gcc

    CFLAGS = -g -O2 -m64 -D__KERNEL__ -D__LINSCHED__ -Wall -Wundef -Wstrict-prototypes \
         -Werror-implicit-function-declaration -fno-common \
         -I${LINSCHED_DIR}/include  -I${LINUXDIR}/include \
         -I${LINUXDIR}/arch/linsched/include -I${LINSCHED_DIR}/ \
             -include ${LINSCHED_DIR}/include/generated/autoconf.h \
         -Wno-pointer-sign -include ${LINUXDIR}/include/linux/kconfig.h

    CFLAGS_LINUX = $(CFLAGS) -nostdinc -isystem $(shell $(CC) -print-file-name=include) \
               -include ${LINSCHED_DIR}/linux_linsched.h \
               -Wno-unused  -Wno-strict-aliasing

    LFLAGS = -lm
....
...
...
 LD_PERCPU = ${LD} -r -T ${LINSCHED_DIR}/linsched.lds

OBJ_FILES = ${LINSCHED_OBJS} ${LINUX_OBJS}
DEPS := ${OBJ_FILES:.o=.d}
-include ${DEPS}

TIME_HDR=${LINUXDIR}/kernel/timeconst.h
${TIME_HDR}: ${LINUXDIR}/kernel/timeconst.pl
    @echo "(Generating timeconst.h)"
    @perl ${LINUXDIR}/kernel/timeconst.pl 1000 > $@

${LINUX_OBJS}: %.o: %.c ${TIME_HDR}
    @echo "CC KERNEL $<"
    @${CC} -o $@ ${CFLAGS_LINUX} -c $< -MMD

%.o: %.c
    @echo "CC SIM $<"
    @${CC} ${CFLAGS} -o $@ -c $< -MMD

网络上有人建议将-lm添加到CFLAGS中,我尝试将-lm参数插入到CFLAGS的多个位置,但同样的错误仍然存​​在。 任何想法???

BTW,我在64位ubuntu下编译了LinSched 3.3,因为在CFLAGS中它被配置为-m64。而在32位Ubuntu下的前编译会引发数据不兼容的错误(在elf64-x86-64和elf32-i386之间)

正如@ another.anon.coward所建议的,我检查了LFLAG如何在以后使用,并发现它是使用的vever。作为解决方案,我应该如何修改makefile以添加LFLAGS参数???

1 个答案:

答案 0 :(得分:0)

实际上问题是链接标志$ {LFLAGS}在/ tools / linsched / tests / Makefile中使用不正确。

以下是修补linsched:

的数学库链接相关构建问题的补丁
git harddeploy