【发布时间】: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。