Help for this page

Select Code to Download


  1. or download this
    // foo.c
    // represents the XS lib referencing a symbol (lgamma) in an external 
    +library libm.so
    ...
        dlclose(so);
        exit(0);
    }
    
  2. or download this
    gcc -c -fPIC foo.c                      # compile
    gcc -shared -o Foo.so foo.o             # create/link shared library F
    +oo.so
    
    gcc -rdynamic -o mytest mytest.c -ldl   # create wrapper executable wh
    +ich loads Foo.so
    
  3. or download this
    $ LD_LIBRARY_PATH=. ./mytest
    dynamically loading 'Foo.so'...
    ./mytest: symbol lookup error: ./Foo.so: undefined symbol: lgamma
    
  4. or download this
    $ gcc -shared -o Foo.so foo.o  -lm
    $ LD_LIBRARY_PATH=. ./mytest
    dynamically loading 'Foo.so'...
    114.034212