autotools-rs icon indicating copy to clipboard operation
autotools-rs copied to clipboard

make phase fails

Open virtualritz opened this issue 2 years ago • 6 comments

I am replacing this code in my build.rs (which works fine):

    let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
    
    Command::new("./configure")
        .current_dir("ta-lib")
        .arg(format!("--prefix={}", out_dir.display()))
        .output()
        .expect("Failed to execute TA C library configure script");

    Command::new("make")
        .current_dir("ta-lib")
        .arg("install")
        .output()
        .expect("Failed to build TA C library");

    println!(
        "cargo:rustc-link-search={}",
        out_dir.join("lib").display()
    );
    println!("cargo:rustc-link-lib=ta_lib");

With this:

    let dst = autotools::build("ta-lib");

    println!("cargo:rustc-link-search=native={}", dst.display());
    println!("cargo:rustc-link-lib=static=ta-lib");

Which fails with several headers not being found, e.g.:

In file included from /Users/moritz/code/crates/ta-lib-rs/ta-lib-sys/ta-lib/src/ta_abstract/ta_group_idx.c:48:
  /Users/moritz/code/crates/ta-lib-rs/ta-lib-sys/ta-lib/src/ta_abstract/ta_def_ui.h:44:13: fatal error: 'ta_abstract.h' file not found
     #include "ta_abstract.h"

What am I missing?

virtualritz avatar Sep 25 '21 11:09 virtualritz

The folder structure of my crate is

ta-lib-sys
├── build.rs
├── Cargo.toml
├── src
│   └── lib.rs
├── ta-lib     # Snapshot of C lib I'm trying to build with autotools
└── wrapper.h

virtualritz avatar Sep 25 '21 11:09 virtualritz

You can also try this yourself. The project is here (with the resp. autotools stuff commented out in Cargo.toml/build.rs): https://github.com/virtualritz/ta-lib-rs/tree/master/ta-lib-sys

virtualritz avatar Sep 26 '21 11:09 virtualritz

The library does not work if you try an out of tree build and should be fixed nonetheless.

lu-zero avatar Sep 26 '21 14:09 lu-zero

You can reproduce by simply doing

mkdir .build
cd .build
{path_to_src}/configure
make

lu-zero avatar Sep 26 '21 14:09 lu-zero

I tried with Config::insource(true) and I get a different error but an error still.

  mv: rename .deps/gen_code-gen_code.Tpo to .deps/gen_code-gen_code.Po: No such file or directory
  make[3]: *** [gen_code-gen_code.o] Error 1
  make[2]: *** [all-local] Error 2
  make[2]: *** Waiting for unfinished jobs....
  make[1]: *** [install-recursive] Error 1
  make: *** [install-recursive] Error 1
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2

On that note: the API Config builder API seems inconsistent. Why are there methods that start with enable_ and take no bool but then there are methods like insource() that do? Also insource() should be in_source(): I mean e.g. either:

Config::static_lib(bool)
Config::in_source(bool)

or:

Config::enable_static()
Config::enable_in_source()

?

virtualritz avatar Sep 27 '21 12:09 virtualritz

Pull requests always welcome :)

lu-zero avatar Sep 27 '21 12:09 lu-zero