Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell FFI for pdflib

Tags:

haskell

ffi

I am trying to write ffi for pdflib library ( pdflib.com ) using c2hs on 64 linux. You can download pdflib from their website for free (fully functional eval.)

I tried to compile and run their hello.c demo program and it works fine.

As far as i understand i need only 2 files to make it work: pdflib.h and libpdf.a

So i put both of them into hello folder, wrote a chs file, it compiles and generates hs file fine. But when i try to compile my Hello.hs program cabal complains

Cabal: Missing dependency on a foreign library: * Missing C library: pdflib

I tried giving it the folder name via --extra-include-dirs and --extra-lib-dirs but it does not help.

How do i compile haskell program with pdflib.h and libpdf.a files ?

like image 698
Vagif Verdi Avatar asked Jun 05 '26 14:06

Vagif Verdi


1 Answers

Migrated from a comment to an answer:

first: I assume you've got "extra-libraries: pdf" like in your cabal file? You need to make sure the name matches precisely (i.e. is the same as the library file but without the 'lib' prefix). second, i've had mixed results with .a files, probably through my own ignorance, but always had success with .so files. – sclv 19 hours ago

like image 105
sclv Avatar answered Jun 07 '26 23:06

sclv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!