Maybe the file needs the standard dynamic library extension on your
platform (.so for Linux, .dylib for OS X, .dll for Windows)?

On Sat, Feb 14, 2015 at 8:19 PM, Dominique Orban <[email protected]>
wrote:

>
> $ cat foo.jl
> run(`gcc foo.c -O3 -dynamiclib -o foo`) #-> compile it
> arg1, arg2, arg3, arg4 = 1, 2, 3, 4;
> val = ccall((:foo, "foo"), Cdouble,(Cdouble, Cdouble, Cdouble, Cdouble),
> arg1,arg2,arg3,arg4)
> println(val);
> $ julia foo.jl
> 10.0
>
>
> On Saturday, February 14, 2015 at 5:01:00 PM UTC-5, Josh Greenhalgh wrote:
>>
>> This is probably a really easy question to answer...
>>
>> I have the following very basic c function;
>>
>>  double foo(double Zx, double Zy, double Cx, double Cy)
>>  {
>>   return Zx + Zy + Cy + Cx;
>>  }
>>
>> it lives in foo.c
>>
>> I try to call in julia using;
>>
>> run(`gcc foo.c -O3 -dynamiclib -o foo`) #-> compile it
>> ccall( (:foo, "foo"), Cdouble,(Cdouble, Cdouble, Cdouble,
>> Cdouble),arg1,arg2,arg3,arg4)
>>
>> it just returns arg1!
>>
>> I'm sure im doing something very silly probably in the c code...any help
>> would be much appreciated!
>>
>>

Reply via email to