[vlc-devel] [patch] Alter symbol-globalising dlopen(RTLD_NOLOAD) call to succeed

jpd at m2x.nl jpd at m2x.nl
Wed Feb 11 22:07:06 CET 2009


Always run dlopen(vlccore,RTLD_NOLOAD) when available and add RTLD_NOW to
prevent the call from failing with an invalid argument error.

diff --git a/src/modules/os.c b/src/modules/os.c
index 53368e4..79f227d 100644
--- a/src/modules/os.c
+++ b/src/modules/os.c
@@ -136,9 +136,11 @@ int module_Call( vlc_object_t *obj, module_t *p_module )
 /* Make sure libvlccore is in the global namespace */
 static void load_libvlccore( void )
 {
-    if( !dlsym( RTLD_DEFAULT, "libvlc_Quit" )
-     && !dlopen( "libvlccore.so", RTLD_GLOBAL|RTLD_NOLOAD ) )
-        fprintf( stderr, "ERROR: failed loading libvlccore\n" );
+    // Need either RTLD_NOW or RTLD_LAZY or the call will fail even with
+    // RTLD_NOLOAD set.
+    if( !dlopen( "libvlccore.so", RTLD_GLOBAL|RTLD_NOLOAD|RTLD_NOW ) )
+        fprintf( stderr, "ERROR: failed loading libvlccore (%s)\n",
+                 dlerror() );
 }
 #endif





More information about the vlc-devel mailing list