Program runs from "cargo run", but not as executable

⚓ rust    📅 2025-06-08    👤 surdeus    👁️ 3      

surdeus

Hi,
I've made a first version of a software in rust, and now want to distribute it. It builds and runs fine when I call "cargo run -r". However, the executable I want to distribute is in target/release/ and when I try to execute it I get the following error:

dyld[39812]: Library not loaded: @rpath/libc++.1.dylib

I am on macOS and I have used the CXX crate to call some C++ code from my software. Does anyone know how cargo executes my program differently from when I simply run it in the terminal (or as part of a packaged .app bundle?).

I can manage to run the program without cargo using "install_name_tool -add_rpath ..." to change the rpath, but then the binary only works on my computer. Is there some way to compile a rust program on macOS that links to C++ code that can run without a cargo install?

2 posts - 2 participants

Read full topic

🏷️ rust_feed