From: James Gessling [jgessling@yahoo.com] Sent: Tuesday, July 23, 2002 10:31 AM To: Info-VAX@Mvb.Saic.Com Subject: How to create a shareable image from an object library (long) I had occasion to do this, so thought I'd share. The object library is libcurl available from http://curl.haxx.se/libcurl/ This library allows you to write programs to do various things that a web browser would do. We use it for programmicaly communicating to web servers with HTTP post and get, but it can do a lot more. The provided build script makes a libcurl.olb which provides the curl_ routines that are called from the application. I could have linked each application against this library, but since the plan was to have several processes running the application at the same time, it made sense to use a shareable image to reduce memory usage. The trick to making the shareable image is to create an option file with all the entry points. This is pretty easy. First list all the entry points in the object library. $ library/list=libcurl.opt/names libcurl.olb In libcurl.opt, you will see a header and then lines like: Module BASE64 CURL_BASE64_DECODE CURL_BASE64_ENCODE Module CONNECT CURL_CONNECTHOST CURL_NONBLOCK There's more than this, but this will do for an example. In your favorite editor, remove all the blank lines and those lines starting with "Module", this now looks like: CURL_BASE64_DECODE CURL_BASE64_ENCODE CURL_CONNECTHOST CURL_NONBLOCK To make these into procedure entries for the symbol_vector, use a learn sequence to make them look like: CURL_BASE64_DECODE=PROCEDURE, - CURL_BASE64_ENCODE=PROCEDURE, - CURL_CONNECTHOST=PROCEDURE, - CURL_NONBLOCK=PROCEDURE, - This library was built from C code using /names=uppercase (the default). I like to provide upper and lower case entry points, especially if a shareable is to be used from different languages. So I added an lower case alias to each entry, like this: CURL_BASE64_DECODE=PROCEDURE, - curl_base64_decode/CURL_BASE64_DECODE=PROCEDURE, - CURL_BASE64_ENCODE=PROCEDURE, - curl_base64_encode/CURL_BASE64_ENCODE=PROCEDURE, - CURL_CONNECTHOST=PROCEDURE, - curl_connecthost/CURL_CONNECTHOST=PROCEDURE, - CURL_NONBLOCK=PROCEDURE, - curl_nonblock/CURL_NONBLOCK=PROCEDURE, - (good time to learn how to do learn sequences in EVE) Add the top and bottom sections to make it a real options file, note removal of last comma. case_sensitive=YES GSMATCH=LEQUAL,1,1000 SYMBOL_VECTOR=( - CURL_BASE64_DECODE=PROCEDURE, - curl_base64_decode/CURL_BASE64_DECODE=PROCEDURE, - CURL_BASE64_ENCODE=PROCEDURE, - curl_base64_encode/CURL_BASE64_ENCODE=PROCEDURE, - CURL_CONNECTHOST=PROCEDURE, - curl_connecthost/CURL_CONNECTHOST=PROCEDURE, - CURL_NONBLOCK=PROCEDURE, - curl_nonblock/CURL_NONBLOCK=PROCEDURE - ) case_sensitive=NO Now create your shareable like this: $ link/share=libcurl.exe libcurl.olb/lib, - libcurl.opt/option, - [--.OPENSSL-0_9_6D.AXP.EXE.SSL]libssl/lib ,- [--.OPENSSL-0_9_6D.AXP.EXE.CRYPTO]libcrypto/lib Needed those other two libraries to support SSL. To link an application using this shareable. $ define libcurl disk:[dir]libcurl.exe $ link /exe=app.exe app.obj,sys$input/opt libcurl/share At runtime be sure the definition of libcurl points to the shareable library so the image activator can find it. As a side benefit linking against the shareable versus the object library is significantly faster, this can make a real difference in large projects. Regards, Jim