Reputation: 41
I'm trying to make a basic image processing program in Rust for a course project, but I'm having trouble figuring out how to start. I've looked into using rust-png, but I'm having difficulty understanding how to use it as an external library as I'm unsure if I'm linking the files correctly. When I compile lib.rs to create the crate I get this error.
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
I'm currently running on the 0.11-pre-nightly build of Rust.
For the project I'm just going to start with using libpng wrappings, but in the future I'd prefer to start from scratch and create my own PNG library for Rust. However, I simply don't know where to begin or if there are any existing image libraries for Rust, be it PNG, GIF or JPEG. Know of any?
Upvotes: 2
Views: 3913
Reputation: 100100
I wrote a wrapper for LodePNG:
it doesn't need any external libraries (besides statically-linked lodepng.c, which it includes), so you shouldn't have any problems linking it.
I've also written bindings and makefile for MozJPEG, which gives you a low-level libjpeg API:
Upvotes: 2