make_dll and call_external woes [message #70469] |
Sun, 18 April 2010 15:02  |
James[2]
Messages: 44 Registered: November 2009
|
Member |
|
|
Hi everyone,
I'm working on some code that's loop-heavy, so I'd like to do the
loopy part with an external C program. I'm using MAKE_DLL to compile
and then CALL_EXTERNAL. My system is Windows XP with the Microsoft
Visual C++ Express compiler, running in 32-bit mode.
I'm using very large data sets, so I would like to pass only pointers
to my C function. I wrote a little test program like this. It takes
all the arguments that my actual program needs, but it just alters one
value to see if anything happens:
void raycast(unsigned char * image, unsigned char * angles, unsigned
char * magnitudes, int * dims)
{
angles[0] = 100;
}
I compile this using MAKE_DLL successfully. I've tested if the code
is getting called by adding an IDL_message(), and it works - the
message prints out on the IDL console. Unfortunately, the above code
does not work. I call it in IDL like this:
[stack is a preexisting 3-dimensional byte array]
dims = fix(size(*stack, /dimensions))
angles = ptr_new(bytarr(dims))
magnitudes = ptr_new(bytarr(dims))
dimsptr = ptr_new(long(reverse(dims)))
call_external (dir + "raycast.dll", "raycast", $
stack, angles, magnitudes, dimsptr, /cdecl, /all_value)
but when I check the value of (*angles)[0] afterward, it's still 0. I
also check with max(*angles) and it's 0 as well. Why is my C program
not changing anything in the array? I get the same problem whether I
include the /ALL_VALUE keyword or not.
Many thanks to anyone who can make sense of this issue!
|
|
|
Re: make_dll and call_external woes [message #70567 is a reply to message #70469] |
Sun, 18 April 2010 16:33   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Apr 18, 6:02 pm, James <donje...@gmail.com> wrote:
> Hi everyone,
>
> I'm working on some code that's loop-heavy, so I'd like to do the
> loopy part with an external C program. I'm using MAKE_DLL to compile
> and then CALL_EXTERNAL. My system is Windows XP with the Microsoft
> Visual C++ Express compiler, running in 32-bit mode.
>
> I'm using very large data sets, so I would like to pass only pointers
> to my C function. I wrote a little test program like this. It takes
> all the arguments that my actual program needs, but it just alters one
> value to see if anything happens:
>
> void raycast(unsigned char * image, unsigned char * angles, unsigned
> char * magnitudes, int * dims)
> {
> angles[0] = 100;
>
> }
>
> I compile this using MAKE_DLL successfully. I've tested if the code
> is getting called by adding an IDL_message(), and it works - the
> message prints out on the IDL console. Unfortunately, the above code
> does not work. I call it in IDL like this:
>
> [stack is a preexisting 3-dimensional byte array]
> dims = fix(size(*stack, /dimensions))
> angles = ptr_new(bytarr(dims))
> magnitudes = ptr_new(bytarr(dims))
> dimsptr = ptr_new(long(reverse(dims)))
> call_external (dir + "raycast.dll", "raycast", $
> stack, angles, magnitudes, dimsptr, /cdecl, /all_value)
>
> but when I check the value of (*angles)[0] afterward, it's still 0. I
> also check with max(*angles) and it's 0 as well. Why is my C program
> not changing anything in the array? I get the same problem whether I
> include the /ALL_VALUE keyword or not.
>
> Many thanks to anyone who can make sense of this issue!
From the documentation:
"/CALL_VALUE. Set this keyword to indicate that all parameters are
passed by value."
Parameters passed by value can be changed by the called routine, but
changes do not appear to the caller.
Craig
|
|
|
|
Re: make_dll [message #75972 is a reply to message #70469] |
Wed, 11 May 2011 06:58  |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Tue, 10 May 2011 14:41:59 -0700 (PDT), Cindy
<cgoethel@igpp.ucla.edu> wrote:
> I'm trying to use make_dll to create a shareable library.
Is this about the serial.dll for Windows 64bit you asked a while back?
If you give me a link to the source code, I can try to build it for
you.
|
|
|
Re: make_dll [message #75976 is a reply to message #70469] |
Tue, 10 May 2011 17:26  |
cgoethel
Messages: 20 Registered: April 2008
|
Junior Member |
|
|
On May 10, 2:47 pm, Michael Galloy <mgal...@gmail.com> wrote:
> On 5/10/11 3:41 PM, Cindy wrote:
>
>> Hello,
>
>> I'm trying to use make_dll to create a shareable library. I get the
>> following error:
>
>> 'cl' is not recognized as an internal or external command, operable
>> program or batch file.
>
>> Is 'cl' referring to 'c linker'? If so, is it a problem that the !
>> dll_make.compiler_name system variable name is Microsoft Visual C++
>> 8.0 while I have Microsoft Visual C++ 10.0 (express) installed on my
>> machine?
>
>> Any comments or suggestions?
>
> It's been awhile since I have had to do this on Windows, but I know I
> have gotten the Express version to work for me with MAKE_DLL. I think
> the problem is that you have to have the right environment variables set
> (I think it is just that cl has to be in the PATH). This happens
> automatically if you launch the MS VS command line (from the Start menu)
> and then run IDL from that command line. Otherwise, you can find the
> location of cl and put it in your PATH (and I think ld also).
>
> Mike
> --
> Michael Galloywww.michaelgalloy.com
> Modern IDL, A Guide to Learning IDL:http://modernidl.idldev.com
> Research Mathematician
> Tech-X Corporation
Thanks for responding! I appreciate your comments. I'll give the MS VS
command line suggestion a try.
|
|
|
Re: make_dll [message #75978 is a reply to message #70469] |
Tue, 10 May 2011 14:47  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 5/10/11 3:41 PM, Cindy wrote:
> Hello,
>
> I'm trying to use make_dll to create a shareable library. I get the
> following error:
>
> 'cl' is not recognized as an internal or external command, operable
> program or batch file.
>
> Is 'cl' referring to 'c linker'? If so, is it a problem that the !
> dll_make.compiler_name system variable name is Microsoft Visual C++
> 8.0 while I have Microsoft Visual C++ 10.0 (express) installed on my
> machine?
>
> Any comments or suggestions?
It's been awhile since I have had to do this on Windows, but I know I
have gotten the Express version to work for me with MAKE_DLL. I think
the problem is that you have to have the right environment variables set
(I think it is just that cl has to be in the PATH). This happens
automatically if you launch the MS VS command line (from the Start menu)
and then run IDL from that command line. Otherwise, you can find the
location of cl and put it in your PATH (and I think ld also).
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
|
|
|