1

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;
polis
  • 795
  • 7
  • 23
  • How do you *try to use that library* exactly? – Eregrith May 11 '15 at 11:36
  • I use it in SAS software. I don't know if it is worth to mention the usage details, because it is completely other technology, also everything works in LINUX environment. I thought, that I have to use some more compile-time arguments because of this error ' Bad magic number'. – polis May 11 '15 at 11:41
  • If same things are working on Linux then surely it is linking issue on your SAS software. please verify if your lib is actually linked during the compilation,. – Dayal rai May 11 '15 at 11:50
  • @Dayalrai could you please give more details how to do that? – polis May 11 '15 at 11:53
  • Can *you* give us more detail on how you try to use the lib, how you link it, and so on? – Eregrith May 11 '15 at 12:11
  • I edited my question with usage details. – polis May 11 '15 at 12:19
  • Is LD_LIBRARY_PATH setting correctly? – Mihai8 May 11 '15 at 12:26
  • LD_LIBRARY_PATH is not used in `proc proto` function. – polis May 11 '15 at 12:58
  • I THINK this is a problem with how your are using the `LINK` statement in `PROC PROTO.` Can you paste the actual line of code here? – DomPazz May 11 '15 at 14:11
  • Actually I've already done that in a question, @DomPazz. – polis May 11 '15 at 15:31
  • @polis, sorry about that. You should send this to SAS Tech Support. This is an error they can probably help you with better than us. – DomPazz May 11 '15 at 15:51
  • PROC PROTO packages are loaded in the order that is specified in the CMPLIB option – Stig Eide May 13 '15 at 07:23

1 Answers1

0

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.

polis
  • 795
  • 7
  • 23