我正在尝试用 Rust 为类(class)项目制作一个基本的图像处理程序,但我不知道如何开始。我研究过使用 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
我目前正在运行 Rust 的 0.11-pre-nightly 版本。
对于该项目,我将首先使用 libpng 包装,但将来我更愿意从头开始并为 Rust 创建自己的 PNG 库。然而,我根本不知道从哪里开始,也不知道是否有任何现有的 Rust 图像库,无论是 PNG、GIF 还是 JPEG。有知道的吗?
最佳答案
我为 LodePNG 编写了一个包装器:
它不需要任何外部库(除了静态链接的 lodepng.c,它包含在内),因此链接它不会有任何问题。
我还为 MozJPEG 编写了绑定(bind)和 makefile,它为您提供了低级 libjpeg API:
关于png - Rust 中的图像处理库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22997888/