CXX is not finding my conan installed library?

I am attempting to use CXX https://cxx.rs/ and Conan-RS GitHub - Devolutions/conan-rs: A Rust wrapper of the conan C/C++ package manager (conan.io) to simplify usage in build scripts to start migrating away from C++.. while still installing a third party library that is required to talk with a remote server.

image

TestCppClient.h

#ifndef BOOTSTRAP_RUST_CPP_CONAN_TESTCPPCLIENT_H
#define BOOTSTRAP_RUST_CPP_CONAN_TESTCPPCLIENT_H

pragma once

#include "EWrapper.h"                <------- From the 3rd party conan lib
#include "EReaderOSSignal.h"
#include "EReader.h"
...

I attempt to build just a simple call to a object in the library but get the following.

* MyApi_helloworld@0.1.1: 
/bootstrap-rust-cpp-conan/target/debug/build/
myapi_helloworld-ee5bd64052f42d0a/out/cxxbridge/
crate/myapi_helloworld/include/TestCppClient.h:6:10: fatal error: EWrapper.h:
No such file or directory

I understand that I need to check that my library actually got installed in the build output.. and indeed I can see not just the library but also the include lines

Build Output showing conan got linked

[myapi_helloworld 0.1.1] cargo:rustc-link-search=native=/home/emcp/.conan/data/myapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/lib
[myapi_helloworld 0.1.1] cargo:rustc-link-lib=myapi

I added a line that hardcoded the needed include path

println!("cargo:rustc-env=CXX_INCLUDE_PATH=/home/emcp/.conan/data/myapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include");

my concern is the EWrapper.h is definitely somewhere in the conan installed area.. I've hard coded it now to build.rs.. and yet still getting this Fatal Error..

Do I need to modify the path to

#include "some/path/conan/include/EWrapper.h"

?

EDIT: Hard coding now working..

but this must have more elegant solution

fn main() {
    let include_path = "/home/emcp/.conan/data/myapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include";

    cxx_build::bridge("src/main.rs")  // path to your bridge file
        .file("src/main.cc")          // your C++ implementation file
        .include(include_path)        // add the include path
        .flag_if_supported("-std=c++11") // any necessary C++ compiler flags
        .compile("twsapi-bridge");    // name for the generated library

    println!("cargo:rerun-if-changed=src/main.rs");
    println!("cargo:rerun-if-changed=src/main.cc");
}

I am very confused.. I got the PathBuf with the same exact string and it's NOT able to find my .h file.. ONLY when I pass it in with a str like above.. does it work and compile without error.. I guess i can live with it but any ideas why this is not accepting vectors of PathBuf ?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.