Re: Using shared objects

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ron Weidner wrote:
> 
> 
> I have some shared object written in C.  Below is the code.  
> What I want is to write a euphoria include that maps the 
> shared object to euphoria.  
> 
> What I'd like even more is if the share object could be 
> distributed as part of the project and not necessarily 
> "installed" on the host.  (ie... no ldconfig).
> 
> So my question is, does anyone have the time to show me 
> how to do it?
> 
> This is what I have ...
> 
> }}}
<eucode>
> #include <stdlib.h>
> #define NUM_DOG 10
> 
> void mush(char**, int);
> int bark();
> 
> void mush(char* dogs[], int len)
> {
> 	int i = 0;
> 	printf("Number of dogs: %d \n", len );
> 	for (i; i < len; i++)
> 	{
> 		printf("Dog named: %s starts mushing...\n", dogs[i]);
> 	}
> }
> 
> int bark()
> {
> 	return 1;
> }
> 
> This is what I want ...
> 
> include dog.e
> if atom(bark()) then
> 	mush({"scooby", "dino", "astro", "spike"}) --notice the absence of arg 2
> end if
> 
> <font color="#330033"></eucode>
{{{
</font>
> 

If I'm understanding correctly.. you want to interface those C routines with
Euphoria? If so.. compile that code with your C compiler into a DLL or SO. Name
it Dog.dll (Windows) or Dog.so (Linux/FreeBSD), then try this code:

-- File extention must be EXW or EXU.

include dll.e

atom dllBark, bark, mush

dllBark = open_dll("Dog.dll")   --  make a DLL/SO of that C code
mush = define_c_proc(dllBark, "mush", {C_CHAR, C_INT})
bark = define_c_func(dllBark, "bark", {}, C_INT)

if atom(c_func(bark, {})) then
    c_proc(mush, {"scooby", "dino", "astro", "spike"})
end if

machine_proc(26, 0) -- pause


I didnt try making a DLL of that code, so their could be a error with my
Euphoria code, but perhaps that will help you out, or maybe I'm way off :P.


Regards,
Vincent

--
Without walls and fences, there is no need for Windows and Gates.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu