You cleared that you have problems, but I would like to provide this link for future visitors, because itβs a little more to create a dynamic library on OS X. Also see Creating dynamic libraries on the pages of Apple developers.
OS X does not use the libcoolstuff.so.XYZ . OS X uses the libcoolstuff.X.dylib . To insert XYZ into the library, use -install_name , -current_version and -compatibility_version .
I do not know Cmake, but here is what it looks like under Make. The recipe for creating libcoolstuff 1.0.6 would look like this:
libcoolstuff libcoolstuff.dylib: $(CC) $(CFLAGS) -dynamiclib -install_name "libcoolstuff.1.dylib" \ -current_version 1.0.6 -compatibility_version 1.0 -o libcoolstuff.1.dylib $(OBJS)
And your make install rule will look like this:
PREFIX?=/usr/local LIBDIR?=$(PREFIX)/lib ... install: cp -f libcoolstuff.1.dylib $(LIBDIR)/libcoolstuff.1.dylib rm -f $(LIBDIR)/libcoolstuff.dylib ln -s $(LIBDIR)/libcoolstuff.1.dylib $(LIBDIR)/libcoolstuff.dylib install_name_tool -change "libcoolstuff.1.dylib" "$(LIBDIR)/libcoolstuff.1.dylib" $(LIBDIR)/libcoolstuff.1.dylib
In otool it looks like this:
$ otool -L libcoolstuff.dylib libcoolstuff.dylib: libcoolstuff.1.dylib (compatibility version 1.0.0, current version 1.0.6) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.7)
Finally, you will use it as expected:
export CFLAGS="-NDEBUG -g2 -O2 -Wall -arch ppc -arch ppc64" make ...
jww Aug 28 '15 at 10:10 2015-08-28 22:10
source share