Re: CALL_EXTERNAL in Linux Fedore Core2??? [message #40917] |
Wed, 08 September 2004 14:13 |
umesh
Messages: 3 Registered: September 2004
|
Junior Member |
|
|
Hi David and Bob,
Thanks a lot for your reply. I changed the names of the files to
braintest.c and braintest.pro and changed the return value to IDL_INT
(;-))
PRO braintest
sc = 5.0
xx=CALL_EXTERNAL('/home/upadiga/work/IDLwork/braintest.so',' braintest',
sc)
print, sc
end
#include <stdio.h>
#include <math.h>
#include "/usr/local/rsi/idl_6.0/external/include/idl_export.h"
float Scale;
IDL_INT braintest(int argc, char *argv[])
{
Scale = *(float *) argv[0];
Scale = pow(Scale, 5);
return(1);
}
and compiled with
gcc -c -fPIC braintest.c
ld -shared -o braintest.so braintest.o
IDL>.r braintest
IDL>braintest
gives me the error message:
% CALL_EXTERNAL: Error loading sharable executable.
Symbol: braintest, File =
/home/upadiga/work/IDLwork/braintest.so
/home/upadiga/work/IDLwork/braintest.so: cannot open
shared
object file: No such file or directory
% Execution halted at: BRAINTEST 4
/home/upadiga/work/IDLwork/braintest.pro
% $MAIN$
This is very similar to the earlier one.
The file "braintest.so" is there in "/home/upadiga/work/IDLwork/"
directory.
I copied the shared library file "braintest.so" to
"/usr/local/rsi/idl_6.0/bin/bin.linux.x86/" and tried again. The error
message is the same. I then copied the "braintest.so" to
"/home/upadiga/.idl/idl_6_0_linux_x86_m32_f64/compile_dir/" and ran the
idl program again but the error message is same!!
Is there any problem in my compilation and loading commands. Do I have to
make some file to direct the dll (like I used make in IDL5.5 on
Windows2000).
Please let me know!
Thanks again,
umesh
If not, I am not sure where is the problem!?
|
|
|
Re: CALL_EXTERNAL in Linux Fedore Core2??? [message #40929 is a reply to message #40917] |
Wed, 08 September 2004 04:46  |
Bob[2]
Messages: 5 Registered: June 2004
|
Junior Member |
|
|
David Grier's remarks are good.
Also: You are including idl_export.h, so it would also be wise to use
IDL_INT for the return type of your 'test' procedure in C -- after you
rename the procedure to something less troublesome, like 'braintest'.
Then in the call_external, you will want to set /IVALUE. I think you
might not have seen these errors yet, since IDL did not find the right
shared object and did not find the symbol.
Also, look through the messages in the list, if you haven't already done
so. There have been several about call_external.
- Bob
umesh wrote:
> Hi!
>
> I am trying to call a simple C program (test.c) from a IDL program using
> CALL_EXTERNAL. The C program is,
>
> #include <stdio.h>
>
> #include <math.h>
>
> #include"/usr/local/rsi/idl_6.0/external/include/idl_export.h "
>
> float Scale;
> int test(int argc, char *argv[])
> xx=CALL_EXTERNAL('/home/upadiga/work/IDLwork/test', $
> '/home/upadiga/work/IDLwork/test', $
> sc)
|
|
|
Re: CALL_EXTERNAL in Linux Fedore Core2??? [message #40930 is a reply to message #40929] |
Tue, 07 September 2004 20:58  |
David G. Grier
Messages: 8 Registered: September 1997
|
Junior Member |
|
|
Hi There,
umesh wrote:
> Hi!
>
> I am trying to call a simple C program (test.c) from a IDL program using
> CALL_EXTERNAL. The C program is,
>
> #include <stdio.h>
>
> #include <math.h>
>
> #include"/usr/local/rsi/idl_6.0/external/include/idl_export.h "
>
> float Scale;
> int test(int argc, char *argv[])
>
> {
>
> Scale = *(float *) argv[0];
>
>
> Scale = pow(Scale, 5);
>
> return(1);
>
> }
>
>
> IDL program is
>
> PRO test
>
> sc = 5.0
> xx=CALL_EXTERNAL('/home/upadiga/work/IDLwork/test', $
> '/home/upadiga/work/IDLwork/test', $
> sc)
Here's the problem. The shared object file is
"/home/upadiga/work/IDLwork/test.so", not
"/home/upadiga/work/IDLwork/test".
That's why the file's not being found.
Furthermore, the object within the library is
"test", not
"/home/upadiga/work/IDLwork/test".
Finally, it's not a good idea to call any routine
"test" because "test" tends to mean something
specific already on most machines.
Hope this helps.
TTFN,
David
>
> print, sc
> end
>
> In directory /home/upadiga/work/IDLwork/test
>
> I have followed following compilation and linking procedures!!
>
>> gcc -c -fPIC test.c
>> ld -shared -o test.so test.o
>
> Then in the IDL command line,
>
> IDL>.r test
> IDL>test
>
> I get the following error message.
>
> % CALL_EXTERNAL: Error loading sharable executable.
> Symbol: /home/upadiga/work/IDLwork/test, File =
> /home/upadiga/work/IDLwork/test
> /home/upadiga/work/IDLwork/test: cannot open shared
> object file: No such file or
> directory
> % Execution halted at: TEST 4
> /home/upadiga/work/IDLwork/test.pro
> % $MAIN$
>
>
> Experts out there, could you please tell me how should I compile and link
> the shared library!? I am using IDL6.0 on Linux (Fedora Core2 64bit OS).
>
> Thanks a lot
>
> umesh
--
============================================================ =============
David G. Grier Department of Physics
(212) 998-3713 (voice) Center for Soft Matter Research
(212) 995-4016 (FAX) New York University
david.grier@nyu.edu 4 Washington Place
http://physics.nyu.edu/grierlab/ New York, NY 10003
============================================================ =============
|
|
|