[haiku-development] Re: missing -lm?

  • From: Grzegorz Dąbrowski <grzegorz.dabrowski@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 29 Apr 2008 08:27:56 +0000

On Mon, 28 Apr 2008 23:57:20 +0200 CEST
"François Revol" <revol@xxxxxxx> wrote:

> > One of the things I've seen come up more than once now in attempting
> > ports is that they bomb out for a missing -lm.
> > It's my understanding the this refers to libm which is a math 
> > library.
> >  Is this included in one of Haiku's libraries?
> > And is the workaround to include a Haiku library rather than -lm,
> > and if so which one is it?
> 
> In Haiku (and BeOS), glibc and libm are both included in libroot and 
> linked to by default.
> It is really wrong to assume library existence, be it libm.
> But since we are the only Unixish OS around that doesn't have it,
> linux freeks often think they can hardcode it.
> The correct fix is to check for it at configure or compile time.
> Remove the -lm from the makefiles, and you can usually add something 
> like:
> AC_CHECK_LIB(m,sqrtf)
> to the configure.ac or .in.
> Sometimes you must add it to a custom FOOLIBS variable instead of
> LIBS, but most of the time it should just work this way.
> 
> There is no reason we should add a hack to work around buggy software.
> AFAIK libm is not mandated by any standard.
> 
> François.
> 

Maybe we should add symlinks like this, what do you think?

diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage
index 8e082dd..022cdc5 100644
--- a/build/jam/HaikuImage
+++ b/build/jam/HaikuImage
@@ -197,6 +197,15 @@ for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) {
        AddSymlinkToHaikuImage beos system lib : libnetwork.so :
$(lib) ; }
 
+# libroot.so replaces quite a few libraries
+BEOS_SYSTEM_LIBS_LIBROOT_ALIASES
+       = libm.so libpthread.so libdl.so ;
+
+local lib ;
+for lib in $(BEOS_SYSTEM_LIBS_LIBROOT_ALIASES) {
+       AddSymlinkToHaikuImage beos system lib : libroot.so : $(lib) ;
+}
+
 # libGL.so has GLUT built-in
 if $(TARGET_ARCH) = x86 {
        AddSymlinkToHaikuImage beos system lib : $(X86_ONLY)libGL.so :
libglut.so ; diff --git a/build/jam/OptionalPackages
b/build/jam/OptionalPackages index d1f51fe..f9937a8 100644
--- a/build/jam/OptionalPackages
+++ b/build/jam/OptionalPackages
@@ -30,7 +30,8 @@ if [ IsOptionalHaikuImagePackageAdded Development ]
        # library symlinks
        local lib ;
        for lib in $(BEOS_SYSTEM_LIBS)
-               $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) libglut.so {
+               $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) libglut.so 
+               $(BEOS_SYSTEM_LIBS_LIBROOT_ALIASES) {
                AddSymlinkToHaikuImage develop lib
x86 : /system/lib/$(lib:BS) ; }

-- 
Grzegorz Dąbrowski



Other related posts: