libcfg+ - Viewing Bug Advanced Details [ Go Back ]
196 building stuff major always 2004-03-07 03:57 2010-11-07 22:31
ejalbert PowerPC  
Mac OS X  
normal 10.3.2  
feedback 0.6.2 (stable)  
N/A open  
none  
none  
Doesn't build on Mac OS X
On Apple's unix-porting list, Marco Baroni (baroni@sslmit.unibo.it) reported that libcfg+-0.6.2 didn't compile on Mac OS X. I was curious, so I took a look and fixed it, albeit not in a way that'll work with your autoconf setup. That'll take a little bit of tweaking.
On Mac OS X, grab the code and run ./configure && make. You'll see this:

ld -shared -o libcfg+.so.0.6.2 ../src/cfg+.o ../src/parse.o ../src/props.o ../src/cmdline.o ../src/cfgfile.o ../src/shared.o ../src/platon/str/strplus.o ../src/platon/str/strctype.o ../src/platon/str/strdyn.o ../src/platon/str/dynfgets.o
ld: unknown flag: -shared
make[1]: *** [libcfg+.so.0.6.2] Error 1
make: *** [all-src] Error 2
There are two problems:
1) Mac OS X uses '.dylib' as its shared library extension, not '.so'.
2) Mac OS X's ld doesn't understand '-shared'. You need to use '-dylib', but that introduces some other complications so it's easier to link with gcc and use '-dynamiclib'.

Here are my diffs. I think the change from $(LD) to $(CC) should be portable, but the use of the -dynamiclib flag and the reworking of the library extension will have to be autoconf'd.

diff -r -u -d -b -w libcfg+-0.6.2/Rules.make.in libcfg+-0.6.2-fixed/Rules.make.in
--- libcfg+-0.6.2/Rules.make.in Tue Feb 17 08:37:47 2004
+++ libcfg+-0.6.2-fixed/Rules.make.in Sat Mar 6 18:42:19 2004
@@ -24,8 +24,8 @@
DISTFILES +=

LIBSTATIC = $(PACKAGE).a
-LIBDYNAMIC = $(PACKAGE).so
-LIBDYNAMICV = $(PACKAGE).so.$(VERSION)
+LIBDYNAMIC = $(PACKAGE).dylib
+LIBDYNAMICV = $(PACKAGE).$(VERSION).dylib

install_LIB = $(LIBSTATIC) $(LIBDYNAMICV)
SCRIPTS =
@@ -160,7 +160,7 @@
$(AR) r $@ $(OBJECTS)

$(LIBDYNAMICV): $(OBJECTS)
- $(LD) $(LDFLAGS) -shared -o $@ $(OBJECTS)
+ $(CC) $(LDFLAGS) -dynamiclib -o $@ $(OBJECTS)

%.o: %.c $(CONFIG_HEADER)
@echo '$(COMPILE) -c $<'; \
diff -r -u -d -b -w libcfg+-0.6.2/src/Makefile.in libcfg+-0.6.2-fixed/src/Makefile.in
--- libcfg+-0.6.2/src/Makefile.in Tue Feb 17 08:37:47 2004
+++ libcfg+-0.6.2-fixed/src/Makefile.in Sat Mar 6 18:40:36 2004
@@ -97,8 +97,8 @@
platon/str/strplus.h

LIBSTATIC = $(PACKAGE).a
-LIBDYNAMIC = $(PACKAGE).so
-LIBDYNAMICV = $(PACKAGE).so.$(VERSION)
+LIBDYNAMIC = $(PACKAGE).dylib
+LIBDYNAMICV = $(PACKAGE).$(VERSION).dylib

install_LIB = $(LIBSTATIC) $(LIBDYNAMICV)


Bug Notes
admin   
2004-03-08 10:32   
Thank you for your bug report.

However we cannot apply your patch, because library will no longer compile on our UNIX system. However we definitely want to add support also for Mac OS X. So if posssible, send you such patch, which will add support for this system. We have no access to Mac OS X, so we will try only if UNIX build is still working properly and believe, that added Mac OS X support works as well.

You can upload files/patches in this bug-tracking system.
chrispix   
2010-11-07 22:31   
The diffs above for linking with gcc worked great for me on OS X Snow Leopard. Thanks!