[asterisk-scf-commits] asterisk-scf/release/ice.git branch "fix-apple-so" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Jun 17 16:16:38 CDT 2011


branch "fix-apple-so" has been created
        at  a3b413eee36959af8895d2b434911c28e761fc81 (commit)

- Log -----------------------------------------------------------------
commit a3b413eee36959af8895d2b434911c28e761fc81
Author: David M. Lee <dlee at digium.com>
Date:   Thu Jan 13 21:29:06 2011 -0600

    Fixed Apple module loading to prefer .so to .dylib.
    
    For Mac OSX, there's a distinction between shared libraries (.dylib)
    and loadable modules (.so).  While things work loading shared libraries
    instead of modules, it causes complications for folks using CMake to
    build their modules.
    * If they build as a module, then it has the .so extension and IceBox
      won't load it.
    * If they build as a library, now IceBbox will load it, but a Windows
      build will build it as a library, and generate a .LIB file that you
      really don't want.

diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index c9be971..cbe3913 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -117,7 +117,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
     {
         lib += "." + version;
     }
-    lib += ".dylib";
+    lib += ".so"; // .so for loadable module on Mach-O
 #elif defined(__hpux)
     lib = "lib" + libName;
     if(!version.empty())
@@ -145,7 +145,27 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
 
     if(!load(lib))
     {
+#ifdef __APPLE__
+        string olderr = _err;
+        // Previous versions of Ice mistakenly loaded .dylib.  If it can't
+        // load a .so, fallback to loading a .dylib.  For more info on
+        // shared libraries (.dylib) vs. loadable modules (.so), see
+        // http://www.finkproject.org/doc/porting/shared.php
+        lib = "lib" + libName;
+        if(!version.empty())
+        {
+            lib += "." + version;
+        }
+        lib += ".dylib";
+        if(!load(lib))
+        {
+            // restore old error message
+            _err = olderr;
+            return 0;
+        }
+#else
         return 0;
+#endif
     }
 
     return getSymbol(funcName);

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice.git



More information about the asterisk-scf-commits mailing list