# How to use candid-extractor?

**URL:** <https://forum.dfinity.org/t/how-to-use-candid-extractor/24771>\
**Category:** Developers\
**Tags:** candid, rust\
**Created:** [November 18, 2023, 1:53am UTC](https://forum.dfinity.org/t/how-to-use-candid-extractor/24771 "2023-11-18T01:53:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [November 18, 2023, 1:53am UTC](https://forum.dfinity.org/t/how-to-use-candid-extractor/24771/1 "2023-11-18T01:53:10Z")

</div>

I was following this [Automatic Candid Generation in Rust: Exploring the ic\_cdk v0.10.0 Update](https://daviddalbusco.com/blog/automatic-candid-generation-in-rust-exploring-the-ic-cdk-v0-10-0-update/)

So,  
I ran `cargo install candid-extractor` in my main terminal ? then I cd to my canister then I ran cargo build then `sh script/did.sh`  
But I got this error

```auto
Error: failed to find function export `get_candid_pointer`

```

Any help please?  
My sh file

```auto
#!/usr/bin/env bash

function generate_did() {
  local canister=$1
  canister_root="src/$canister"

  cargo build --manifest-path="$canister_root/Cargo.toml" \
      --target wasm32-unknown-unknown \
      --release --package "$canister"

  candid-extractor "target/wasm32-unknown-unknown/release/$canister.wasm" > "$canister_root/$canister.did"
}

CANISTERS=user_canister

for canister in $(echo $CANISTERS | sed "s/,/ /g")
do
    generate_did "$canister"
done

```

here is a photo of my project tree

 ![Screenshot 2023-11-18 at 4.57.17 AM](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/7/7c098a1ff338548ae0f04a929ddd342512edb544.png)

Also, it is intersting that `echo $canister_root/$canister` shows `user_canister/user_canister`  
I also added

```rs
ic_cdk_macros::export_candid!();

```

at the end of the file `user_canister/lib.rs`

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [November 18, 2023, 2:49am UTC](https://forum.dfinity.org/t/how-to-use-candid-extractor/24771/2 "2023-11-18T02:49:47Z")

</div>

solved by adding all the struct to lib.rs and make them public also somthing like

```auto
use user::*;
use files::*;
use files_content::*;
use contracts::*;
use friends::*;
use share_files::*;
use std::collections::HashMap;
use queries::*;
use updates::*;
use ic_websocket_cdk::*;
use websocket::*;

```

---

<div class="post-metadata">

**Author:** ![ohsalmeron](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ohsalmeron/32/30099_2.png) [@ohsalmeron](https://forum.dfinity.org/u/ohsalmeron)\
**Post date:** [January 3, 2024, 9:27pm UTC](https://forum.dfinity.org/t/how-to-use-candid-extractor/24771/3 "2024-01-03T21:27:53Z")

</div>

```auto
[bizkit@archlinux cosmicrafts_icp]$ npm run generate

> cosmicrafts_icp_frontend@0.2.0 generate
> scripts/did.sh && dfx generate && npm run format

    Finished release [optimized] target(s) in 0.05s
Error: failed to find function export `get_candid_pointer`

```

yeah same issue here, I also tried to add allthe s truct to lib.rs and make it public, but for me it didn’t work

```auto
use candid::*;

use std::cell::*;

use serde::*;

use ic_cdk_macros::*;

use ic_websocket_cdk::*;

use canister::*;

```

Did you also do the  
ic\_cdk\_macros::export\_candid!();

on your other rust scripts or just on the lib.rs?  
also, I’ve read on David’s blog something about the candid methods that must be removed, how did you manage to do that?
