Hello,
I have problems with drops and the std C mathematical library. For my project, I am working on a package which is linked against a static user-library. This library on itslef uses <math.h>, e.g. the functions sin, cos, pow, a.s.o. ..., and is linked by gcc with "-lm".
When linking the executable of the package without including "-lm" in "LIBS" of the package Makefile, simmilar output messages are generated:
../../../../../lib/x86_586/l4v2/my-user-lib.a(src_file.o): In function `myFunc': src_file.c:(.text+0x466): undefined reference to `log' src_file.o:(.text+0x477): undefined reference to `log' src_file.o:(.text+0x490): undefined reference to `pow' src_file.o:(.text+0x490): undefined reference to `sqrt' src_file.o:(.text+0x490): undefined reference to `cos' src_file.o:(.text+0x525): undefined reference to `__assert_fail' ...
I am linking in "l4env_freebsd" mode and the appropiate user-library is found, as I assume by the output message, but not the implementation of the <math.h> functions, which should come with a libm.a ...
Linking with "-lm" in the freebsd mode sends the following output:
../../../../../lib/x86_586/l4v2/my-user-lib.a(src_file.o): In function `myFunc': src_file.c:(.text+0x525): undefined reference to `__assert_fail' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__errno_location' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__errno_location' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__errno_location' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__errno_location' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__errno_location' /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o):: more undefined references to `__errno_location' follow /usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../libm.a(k_standard.o): In function `__kernel_standard': : undefined reference to `__assert_fail' collect2: ld returned 1 exit status
Does anyone have any solution for this problem? I thought about searching another math library, which does not use standard C math functions and trying to compile it as a library in a drops package by including 'lib.mk' in the appropiate Makefile. I am not really shure, if this would really solve my problem, or just keep me fighting with other incompatibility problems. Is there no other possibility to use mathematical functions in any drops application, or perhaps another linkage concept or configuration? I hope for some replies ;-)
Vladimir
Hi Vladimir,
[...]
Does anyone have any solution for this problem? I thought about searching another math library, which does not use standard C math functions and trying to compile it as a library in a drops package by including 'lib.mk' in the appropiate Makefile. I am not really shure, if this would really solve my problem, or just keep me fighting with other incompatibility problems. Is there no other possibility to use mathematical functions in any drops application, or perhaps another linkage concept or configuration?
I see two ways for you to proceed:
1) Try another mode, e.g. a dietlibc mode. I built the dietlibc such, that a libm is already included.
2) Write a *minimal* example which triggers the problem in the freebsd mode, maybe someone can tell more from this. FYI, the freebsd mode is unmaintained now.
Cheers, Martin
Hi Martin, thank you for your reply, I have tried to compile my code in the "l4env_diet" MODE and everything was okay then! The library, which I used to link with my drops package, uses internally <math.h> functions for doing some FFT and MDCT. I didn't know about this build-mode, I used always the modes as described on the 'bid-spec' tutorial from the L4Env webpage ( http://os.inf.tu-dresden.de/l4env/doc/ ), so thanks for the suggestion! Regards
Vladimir
Martin Pohlack schrieb:
Hi Vladimir,
[...]
Does anyone have any solution for this problem? I thought about searching another math library, which does not use standard C math functions and trying to compile it as a library in a drops package by including 'lib.mk' in the appropiate Makefile. I am not really shure, if this would really solve my problem, or just keep me fighting with other incompatibility problems. Is there no other possibility to use mathematical functions in any drops application, or perhaps another linkage concept or configuration?
I see two ways for you to proceed:
- Try another mode, e.g. a dietlibc mode. I built the dietlibc such,
that a libm is already included.
- Write a *minimal* example which triggers the problem in the freebsd
mode, maybe someone can tell more from this. FYI, the freebsd mode is unmaintained now.
Cheers, Martin
l4-hackers@os.inf.tu-dresden.de