1. Making your own shared libraries
- Posted by Robert Craig <rds at ATTCANADA.NET> Jul 18, 1999
- 320 views
Here's an example of how you can write your own C routines and add them to your Linux Euphoria program. Making a shared library with gcc isn't well documented, but is actually very simple. 1. Create a C source file, say, mylib.c and define one or more C functions : int sum(int x) { int i, sum; sum = 0; for (i = 1; i <= x; i++) sum += i; return sum; } 2. Create a Euphoria program, mylib.exu: include dll.e atom mylib integer sum mylib = open_dll("./mylib.so") if mylib = NULL then puts(2, "Couldn't open mylib.so\n") abort(1) end if sum = define_c_func(mylib, "sum", {C_INT}, C_INT) ? c_func(sum, {10}) -- calls your C routine 3. Make a shared library from your C source file: gcc -shared mylib.c -o mylib.so 4. Run your Euphoria program: exu mylib The output is: 55 - the sum of the integers from 1 to 10. Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/
2. Re: Making your own shared libraries
- Posted by JJProg at CYBERBURY.NET Jul 18, 1999
- 306 views
EU>Here's an example of how you can write your EU>own C routines and add them to your Linux Euphoria EU>program. Making a shared library with gcc EU>isn't well documented, but is actually very simple. EU>1. Create a C source file, say, mylib.c EU>and define one or more C functions : EU>2. Create a Euphoria program, mylib.exu: EU>3. Make a shared library from your C source file: EU>gcc -shared mylib.c -o mylib.so EU>4. Run your Euphoria program: EU>exu mylib EU>Regards, EU> Rob Craig EU> Rapid Deployment Software EU> http://members.aol.com/FilesEu/ Are you going to add this to Euphoria for DOS at some point? I think DJGPP supports the same kind of thing since it's a port of GCC, though I haven't looked into it. Jeffrey Fielding JJProg at cyberbury.net http://members.tripod.com/~JJProg/
3. Re: Making your own shared libraries
- Posted by Robert Craig <rds at ATTCANADA.NET> Jul 19, 1999
- 321 views
Jeffrey Fielding writes (regarding dynamic linking): > Are you going to add this to Euphoria for DOS at > some point? I think DJGPP supports the same kind > of thing since it's a port of GCC, though I haven't looked > into it. I don't think dynamic linking is well supported by DJGPP. There may be a few crude "hacks" around, but nothing solid. I wouldn't switch from WATCOM to DJGPP just for that. Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/