简体   繁体   中英

How to create shared library with gcc in hp-ux?

I try to create a shared library with gcc compiler on hp-ux. I use these commands:

  1. gcc -Wall -fPIC -std=gnu99 -c *.c
  2. gcc -shared -Wl -o my_library.so *.o

Everything compiles without warnings or errors, but when I try to use that library, I get an error:

ERROR: Extension Load Failure: OS Error: -1 (' path_to_lib ' is not a valid load module: Bad magic number). ERROR: Unable to load extension: ( path_to_lib ).
ERROR: Extension Load Failure: OS Error: -1 (' path_to_lib ' is not a valid load module: Bad magic number)

Do you know what does this error exactly mean? How to fix it?

EDITED: I use my shared library in SAS program like this:

proc proto package =work.myfuncs.tests;
   link "/home/my_library.so";

   int test(int x);
run;

I finally resolved my problem. I had to create library as 64 bits library with gcc option -mlp64 , because SAS software was 64 bits. However, I still don't know why proc proto worked correctly on LINUX, because SAS software is 64b there too. Maybe it had too be something with different gcc instalations over these two environments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM