Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make phase fails #23

Open
virtualritz opened this issue Sep 25, 2021 · 6 comments
Open

make phase fails #23

virtualritz opened this issue Sep 25, 2021 · 6 comments

Comments

@virtualritz
Copy link

virtualritz commented Sep 25, 2021

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
Copy link
Author

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
Copy link
Author

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

@lu-zero
Copy link
Owner

lu-zero commented Sep 26, 2021

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

@lu-zero
Copy link
Owner

lu-zero commented Sep 26, 2021

You can reproduce by simply doing

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

@virtualritz
Copy link
Author

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()

?

@lu-zero
Copy link
Owner

lu-zero commented Sep 27, 2021

Pull requests always welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants