[Nexus-developers] Autotools linking on Mac OS X

Ray Osborn ROsborn at anl.gov
Mon Feb 23 07:15:16 GMT 2004


Last week, I reported on some problems using autotools on Mac OS X.  Several
were fixed very promptly by Jens and Freddie, but the following remain:

1) Actually, the first has nothing to do with autotools (I don't think).  I
get the following compilation error.

napi5.c: In function `NX5open':
napi5.c:202: error: `cacheSize' undeclared (first use in this function)

cacheSize is defined in napi.c, but not in napi5.c.  If I add the
declaration

 long cacheSize 

to NX5open, then it compiles without problem (although I haven't confirmed
that the compiled version works - see problem 2).

I haven't been able to work out the history of this bug.  Does anyone else
even get this bug? If my fix is correct, please add it to the repository.

2) We don't seem to have the dynamic library options set properly for Mac OS
X, and I don't have the expertise to fix it.  The error is seen here at the
first link command (the compilations have all worked).

gcc -dynamiclib  -flat_namespace -undefined suppress -o
..libs/libNeXus.0.dylib  .libs/napi.o .libs/napi4.o .libs/napi5.o  -L/sw/lib
/sw/lib/libhdf5.dylib -lmfhdf -ldf /sw/lib/libjpeg.dylib -lz -install_name
/usr/local/lib/libNeXus.0.dylib -compatibility_version 1 -current_version
1.0
ld: common symbols not allowed with MH_DYLIB output format with the
-multi_module option

When I googled to find out if anyone had a solution to this, a few sources
suggested adding -fno-common to the compilation switches.  I added it to the
CFLAGS environment variable, but it didn't make any difference although I
could see that it was added to the compilation commands.

I later tried adding it to LDFLAGS, but it didn't get added to the above gcc
command.  When I put it in manually, I got the same error.

As an aside, there is a reference to the -fno-common switch in ltmain.sh,
but it doesn't get added to the gcc compiles unless I explicitly put it in
CFLAGS.

I tried substituting -bundle (which used to be recommended instead of
/shared) for -dynamiclib, but that is apparently not allowed with this
compatibility_version.

If it's any use, there are some tips on porting dynamic libraries in:

<http://fink.sourceforge.net/doc/porting/index.php>
<http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/ind
ex.html>

Ray
-- 
Dr Ray Osborn                Tel: +1 (630) 252-9011
Materials Science Division   Fax: +1 (630) 252-7777
Argonne National Laboratory  E-mail: ROsborn at anl.gov
Argonne, IL 60439-4845




More information about the NeXus-developers mailing list