【问题标题】:Image Processing Libraries in RustRust 中的图像处理库
【发布时间】:2014-05-24 17:47:17
【问题描述】:

我正在尝试用 Rust 为一个课程项目制作一个基本的图像处理程序,但我不知道如何开始。我已经研究过使用rust-png,但我很难理解如何将它用作外部库,因为我不确定我是否正确链接了文件。当我编译 lib.rs 来创建 crate 时,我得到了这个错误。

error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'main' 'main.o' '-lmorestack' '-nodefaultlibs' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libnative-83574243-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-aad93cea-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-8f65d5a8-0.10-pre.rlib' '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project/.rust' '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project' '-lpng' '-lz' '-lshim' '-lSystem' '-lc' '-lm' '-Wl,-rpath,@loader_path/../../../../../../../usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lcompiler-rt'
note: ld: warning: directory not found for option '-L/Users/brianuosseph/Desktop/Course_Work/Spring_2014/CS_4414/final_project/.rust'
ld: library not found for -lshim
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error

我目前正在运行 0.11-pre-nightly 版本的 Rust。

对于这个项目,我只是从使用 libpng 包装开始,但将来我更愿意从头开始,为 Rust 创建我自己的 PNG 库。但是,我根本不知道从哪里开始,或者是否有任何现有的 Rust 图像库,无论是 PNG、GIF 还是 JPEG。知道吗?

【问题讨论】:

  • 看起来为了编译rust-png,你必须先运行./configure,然后运行make。您问题中的错误将消失(shim 库似乎是一个非常简单的库,由同一存储库中的 shim.c 文件编译而成)。
  • 当试图编译 'shim.c' 或运行 'make' 我遇到同样的错误 ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (使用 -v 查看调用)有什么方法可以获得所需的符号?
  • 这很奇怪。我只有git cloned 库,运行./configure,编辑Makefile 以设置Rust 编译器的路径并执行make。一切都编译得很好,我有 .rlib.so 库。也许这个库不适合 Mac OS X。

标签: png rust libpng


【解决方案1】:

我为 LodePNG 写了一个包装器:

https://lib.rs/lodepng

它不需要任何外部库(除了静态链接的 lodepng.c,它包括),所以链接它应该没有任何问题。


我还为 MozJPEG 编写了绑定和 makefile,它为您提供了一个低级 libjpeg API:

https://lib.rs/mozjpeg-sys

【讨论】:

    猜你喜欢
    • 2012-10-03
    • 1970-01-01
    • 2010-10-04
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    • 2011-11-21
    • 2010-12-14
    • 1970-01-01
    相关资源
    最近更新 更多