FFI with compile flags

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

FFI with compile flags

Annick Fron-3
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick
Reply | Threaded
Open this post in threaded view
|

Re: FFI with compile flags

Clément Béra
I don't understand, do you want to compile your library using FFI or do you want to bind a library compiled your way with FFI ?

If you want to compile your library using FFI, then use OSProcess to run the compilation line you showed.

If you want to bind a library compiled your way with FFI, the easiest way is to compile the C files as a dylib with something like:

gcc -shared -m32 -Wall helloworld.c -o helloworld.dylib $(pkg-config --cflags --libs gstreamer-1.0)

(replace .dylib by .so or .dll if you're on windows or on Mac).
Then you can bind the dynamic library generated with FFI. I am not sure about the FFI syntax but with NativeBoost it would look like:
Integer>>fib4NB
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( int functionToCall (int self) )
        module: '/Users/myName/Desktop/helloWorld.dylib'

Regards,

Clement


2014-08-13 11:55 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick

Reply | Threaded
Open this post in threaded view
|

Re: FFI with compile flags

Annick Fron-3
I want to interface some pharo code with gstreamer. But gstreamer does not come up with a dylib, it requires compilation flags for instance for a C program.
The compile options are :
-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0

so if I don’t know which module to use in FFI. If I put 
/usr/lib/gstreamer-1.0
 I get an error « module not found ».
Since it is handled by pragmas it is very difficult to debug.

Annick
Le 13 août 2014 à 13:11, Clément Bera <[hidden email]> a écrit :

I don't understand, do you want to compile your library using FFI or do you want to bind a library compiled your way with FFI ?

If you want to compile your library using FFI, then use OSProcess to run the compilation line you showed.

If you want to bind a library compiled your way with FFI, the easiest way is to compile the C files as a dylib with something like:

gcc -shared -m32 -Wall helloworld.c -o helloworld.dylib $(pkg-config --cflags --libs gstreamer-1.0)

(replace .dylib by .so or .dll if you're on windows or on Mac).
Then you can bind the dynamic library generated with FFI. I am not sure about the FFI syntax but with NativeBoost it would look like:
Integer>>fib4NB
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( int functionToCall (int self) )
        module: '/Users/myName/Desktop/helloWorld.dylib'

Regards,

Clement


2014-08-13 11:55 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick


Reply | Threaded
Open this post in threaded view
|

Re: FFI with compile flags

stepharo
Annick

FFI can call a function but it needs to know where is your library.

Stef

On 13/8/14 15:46, Annick Fron wrote:
I want to interface some pharo code with gstreamer. But gstreamer does not come up with a dylib, it requires compilation flags for instance for a C program.
The compile options are :
-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0

so if I don’t know which module to use in FFI. If I put 
/usr/lib/gstreamer-1.0
 I get an error « module not found ».
Since it is handled by pragmas it is very difficult to debug.

Annick
Le 13 août 2014 à 13:11, Clément Bera <[hidden email]> a écrit :

I don't understand, do you want to compile your library using FFI or do you want to bind a library compiled your way with FFI ?

If you want to compile your library using FFI, then use OSProcess to run the compilation line you showed.

If you want to bind a library compiled your way with FFI, the easiest way is to compile the C files as a dylib with something like:

gcc -shared -m32 -Wall helloworld.c -o helloworld.dylib $(pkg-config --cflags --libs gstreamer-1.0)

(replace .dylib by .so or .dll if you're on windows or on Mac).
Then you can bind the dynamic library generated with FFI. I am not sure about the FFI syntax but with NativeBoost it would look like:
Integer>>fib4NB
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( int functionToCall (int self) )
        module: '/Users/myName/Desktop/helloWorld.dylib'

Regards,

Clement


2014-08-13 11:55 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick



Reply | Threaded
Open this post in threaded view
|

Re: FFI with compile flags

Annick
Steph

We had a Skype call yesterday with JB, and we made progress.
The problem is I have several libraries, and it was not easy to find because they don’t export symbols and use pkg-config.

See you in Cambridge
Annick
Le 15 août 2014 à 12:36, stepharo <[hidden email]> a écrit :

Annick

FFI can call a function but it needs to know where is your library.

Stef

On 13/8/14 15:46, Annick Fron wrote:
I want to interface some pharo code with gstreamer. But gstreamer does not come up with a dylib, it requires compilation flags for instance for a C program.
The compile options are :
-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0

so if I don’t know which module to use in FFI. If I put 
/usr/lib/gstreamer-1.0
 I get an error « module not found ».
Since it is handled by pragmas it is very difficult to debug.

Annick
Le 13 août 2014 à 13:11, Clément Bera <[hidden email]> a écrit :

I don't understand, do you want to compile your library using FFI or do you want to bind a library compiled your way with FFI ?

If you want to compile your library using FFI, then use OSProcess to run the compilation line you showed.

If you want to bind a library compiled your way with FFI, the easiest way is to compile the C files as a dylib with something like:

gcc -shared -m32 -Wall helloworld.c -o helloworld.dylib $(pkg-config --cflags --libs gstreamer-1.0)

(replace .dylib by .so or .dll if you're on windows or on Mac).
Then you can bind the dynamic library generated with FFI. I am not sure about the FFI syntax but with NativeBoost it would look like:
Integer>>fib4NB
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( int functionToCall (int self) )
        module: '/Users/myName/Desktop/helloWorld.dylib'

Regards,

Clement


2014-08-13 11:55 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick




Reply | Threaded
Open this post in threaded view
|

Re: FFI with compile flags

Denis Kudriashov


2014-08-15 14:03 GMT+01:00 Annick Fron <[hidden email]>:
Steph

We had a Skype call yesterday with JB, and we made progress.
The problem is I have several libraries, and it was not easy to find because they don’t export symbols and use pkg-config.

See you in Cambridge
Annick
Le 15 août 2014 à 12:36, stepharo <[hidden email]> a écrit :

Annick

FFI can call a function but it needs to know where is your library.

Stef

On 13/8/14 15:46, Annick Fron wrote:
I want to interface some pharo code with gstreamer. But gstreamer does not come up with a dylib, it requires compilation flags for instance for a C program.
The compile options are :
-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0

so if I don’t know which module to use in FFI. If I put 
/usr/lib/gstreamer-1.0
 I get an error « module not found ».
Since it is handled by pragmas it is very difficult to debug.

Annick
Le 13 août 2014 à 13:11, Clément Bera <[hidden email]> a écrit :

I don't understand, do you want to compile your library using FFI or do you want to bind a library compiled your way with FFI ?

If you want to compile your library using FFI, then use OSProcess to run the compilation line you showed.

If you want to bind a library compiled your way with FFI, the easiest way is to compile the C files as a dylib with something like:

gcc -shared -m32 -Wall helloworld.c -o helloworld.dylib $(pkg-config --cflags --libs gstreamer-1.0)

(replace .dylib by .so or .dll if you're on windows or on Mac).
Then you can bind the dynamic library generated with FFI. I am not sure about the FFI syntax but with NativeBoost it would look like:
Integer>>fib4NB
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( int functionToCall (int self) )
        module: '/Users/myName/Desktop/helloWorld.dylib'

Regards,

Clement


2014-08-13 11:55 GMT+02:00 Annick Fron <[hidden email]>:
Hi,

I would like to compile a FFI program but the compiling implies compile flags like in the following :

gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0)

How do I do this with FFI ?

Annick