Unable to install Aspose.PDF for Rust via C++ on linux

I have tried to install Aspose.PDF for Rust via C++ on linux Mint (Ubuntu 24) in a number of ways using the apose github procedures. In all cases I can build the rust sample application including aspose but when trying to run the app I always get " …/target/debug/pdttospread: error while loading shared libraries: libAsposePDFforRust_linux_amd64.so: cannot open shared object file: No such file or directory"

sgraf@grafcs:~/Documents/kmymoney/pdf/pdttospread/src$ ls -alh $ASPOSE_PDF_LIB_DIR
total 454M
drwxrwxr-x 2 sgraf sgraf 4.0K Feb 20 10:42 .
drwxrwxr-x 3 sgraf sgraf 4.0K Feb 20 10:39 …
-rw-rw-r-- 1 sgraf sgraf 358M Feb 20 10:42 libAsposePDFforRust_linux_amd64.so
-rw-rw-r-- 1 sgraf sgraf 97M Feb 20 10:36 libAsposePDFforRust_linux_amd64.so.bz2
-rw-rw-r-- 1 sgraf sgraf 65 Feb 20 10:37 libAsposePDFforRust_linux_amd64.so.bz2.sha256

@stephengraf

You’re seeing the loader error because the dynamic linker cannot find libAsposePDFforRust_linux_amd64.so at runtime, even though the file is present in the directory pointed to by $ASPOSE_PDF_LIB_DIR.

How to make the library discoverable

  1. Add the library directory to LD_LIBRARY_PATH before running the program:

    export LD_LIBRARY_PATH=$ASPOSE_PDF_LIB_DIR:$LD_LIBRARY_PATH
    ./target/debug/pdttospread
    

    Replace $ASPOSE_PDF_LIB_DIR with the full path (e.g. ~/Documents/kmymoney/pdf/pdttospread/src).

  2. Persist the setting (optional) – add the export line to ~/.bashrc or to a wrapper script that launches your app.

  3. System‑wide alternative – copy the shared library to a standard library directory and refresh the linker cache:

    sudo cp $ASPOSE_PDF_LIB_DIR/libAsposePDFforRust_linux_amd64.so /usr/local/lib/
    sudo ldconfig
    
  4. Embed an RPATH in the binary (cargo projects) – add a build.rs that tells the linker where to look:

    // build.rs
    fn main() {
        println!("cargo:rustc-link-search=native={}", std::env::var("ASPOSE_PDF_LIB_DIR").unwrap());
        // If you place the .so next to the executable:
        println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
    }
    

    Re‑run cargo build and then execute the binary.

  5. Verify the linker can see the library:

    ldd ./target/debug/pdttospread | grep AsposePDFforRust
    

    The output should show the full path to libAsposePDFforRust_linux_amd64.so instead of “not found”.

If the problem remains

  • Confirm that LD_LIBRARY_PATH is exported in the same shell where you run the program (echo $LD_LIBRARY_PATH).
  • Check that the library file is readable by your user (chmod 644 libAsposePDFforRust_linux_amd64.so).
  • Ensure both the executable and the shared library are built for the same architecture (amd64) using file on each.

Let me know whether the executable starts after these steps or if you encounter a different error.

Thank you for the reply.
I used option 3 (System‑wide alternative) to fix the problem.

The README on GitHub - aspose-pdf/aspose-pdf-rust-cpp: Aspose.PDF for Rust via C++ should contain this information or better still the build procedure should set up the required linkages.

I had tried the the github build procedure before and it failed also even though it specifically says: “The build script links the appropriate native library and ensures runtime availability using platform-specific options.”

@stephengraf

We are checking it and will get back to you shortly.

Hi @stephengraf,

Thank you for reporting this and helping us clarify the runtime behavior - it helped us remove ambiguity in the documentation.

Please note that as of 24‑02‑2026 a new version 1.26.2 is available, and the README and crates.io page have been updated with clear instructions on Runtime Configuration:

GitHub README: Runtime Configuration

Crates.io: Aspose.PDF crate page

Your situation:

The error you encountered:

…/target/debug/pdttospread: error while loading shared libraries: libAsposePDFforRust_linux_amd64.so: cannot open shared object file

happens because Linux requires the dynamic loader to know where the .so file is at runtime. Cargo links the library at compile time, but due to limitations in Rust/Cargo, our library cannot automatically configure the runtime search path for your executable.

Your workaround (copying the .so to /usr/local/lib and running ldconfig) works, but for development we recommend using RPATH (via .cargo/config.toml or RUSTFLAGS), which tells the binary to search for libraries in its own folder (target/debug or target/release).

The updated documentation now clearly explains:

How to set ASPOSE_PDF_LIB_DIR for build

How to configure runtime search paths RPATH for Linux and macOS.

This ensures the executable can find the native library without system-wide installation.

If you encounter any questions or difficulties, we will be happy to assist you.