Cargo+nasm: nasm: error: more than one input file specified


I’m new to Rust and this is on OSX.

I have X86 assembly which normally assembles with nasm using a Makefile. The assembly line looks like:

nasm -f macho64 glue.s -o glue.o

I’ve rewritten my driver in Rust and that works. Now I’m trying to build everything with Cargo. My is a pretty straightforward copy of the example from


use std::process::Command;
use std::path::Path;
use std::env;

fn main() {
let out_dir = env::var(“OUT_DIR”).unwrap();

Command::new("nasm").args(&["src/glue.s", "-fmacho64"])
                   .arg(&format!("{}/glue.o", out_dir))

Command::new(“ar”).args(&[“crus”, “libglue.a”, “glue.o”])

println!("cargo:rustc-link-search=native={}", out_dir);


This doesn’t work. When I build it with cargo build -vv I get:

Running ..../build-script-build
nasm: error: more than one input file specified
type nasm -h' for help nasm: error: more than one input file specified typenasm -h’ for help
ar: glue.o: No such file or directory

However, I have no idea why nasm is complaining about more than one input file specified. The -vv option doesn’t print the offending nasm command just the error message (which is helpful). Again, my code looks very very similar to the example.



Well, I think I can answer my own question.
The output argument for nasm needs a -o argument:

Command::new("nasm").args(&["src/glue.s",   "-fmacho64", "-o"])
                   .arg(&format!("{}/glue.o", out_dir))


I am also using nasm in a build script, and almost wrote a crate for it to make it easier, but haven’t yet. Maybe i’ll do that; I’ll let you know :smile:


Oh look, there is one:

and one that’s defunct with a better name:

Gonna email some people and see if we can fix this :smile: