用于 pdflib 的 Haskell FFI
我正在尝试在 64 位 Linux 上使用 c2hs 为 pdflib 库( pdflib.com )编写 ffi 。 您可以从他们的网站免费下载 pdflib(功能齐全的评估)。
我尝试编译并运行他们的 hello.c 演示程序,它工作正常。
据我了解,我只需要 2 个文件即可使其工作: pdflib.h 和 libpdf.a
所以我将它们都放入 hello 文件夹中,编写了一个 chs 文件,它编译并生成了 hs 文件。 但是当我尝试编译我的 Hello.hs 程序时,cabal 抱怨
Cabal:缺少对外国库的依赖: * 缺少 C 库:pdflib
我尝试通过 --extra-include-dirs 和 --extra-lib-dirs 为其提供文件夹名称,但没有帮助。
如何使用 pdflib.h 和 libpdf.a 文件编译 haskell 程序?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从评论迁移到答案:
首先:我假设您有“额外的库:pdf”,就像您的 cabal 文件中一样?您需要确保名称精确匹配(即与库文件相同但没有“lib”前缀)。其次,我对 .a 文件的结果好坏参半,可能是因为我自己的无知,但对 .so 文件总是成功。 – sclv 19 小时前
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
链接器需要能够找到您的 .a 文件。它将在通常的 /usr/lib 路径中查找。您可以将 pdflib 安装到常规系统位置(例如通过包管理器)吗?这将是最简单的路径。
The linker will need to be able to find your .a file. It will look in the usual /usr/lib paths. Can you install pdflib into the regular system locations (e.g. via your package manager)? This will be the easiest path.