# Build Documentation out of date?

**URL:** <https://community.konduit.ai/t/build-documentation-out-of-date/180>\
**Category:** DL4J\
**Created:** [February 26, 2020, 5:17pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180 "2020-02-26T17:17:21Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![tc64](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/tc64/32/77_2.png) [@tc64](https://community.konduit.ai/u/tc64)\
**Post date:** [February 27, 2020, 12:29am UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/21 "2020-02-27T00:29:46Z")

</div>

Hi @treo I’m working on this with @zamlz. Thanks for all the help!

I’m wondering, where would we add custom build flags, such as -g ?

Also, how would we get our project to use this locally compiled version of nd4j as opposed to the one from maven central? Not sure what to do with our pom to make that happen.

---

<div class="post-metadata">

**Author:** ![AlexBlack](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/alexblack/32/25_2.png) [@AlexBlack](https://community.konduit.ai/u/AlexBlack)\
**Post date:** [February 27, 2020, 12:34am UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/22 "2020-02-27T00:34:27Z")

</div>

> [@tc64](#):
>
> Also, how would we get our project to use this locally compiled version of nd4j as opposed to the one from maven central? Not sure what to do with our pom to make that happen.

If you switch your version to 1.0.0-SNAPSHOT, it’ll use the installed version instead of the Maven Central version (which is 1.0.0-beta6 only)  
One thing to be aware of: if you have the snapshots repo set up in your project - which isn’t necessary I should add when doing a local build (as described [here](https://deeplearning4j.org/docs/latest/deeplearning4j-config-snapshots)) - maven can decide to download and use the new snapshots instead of using the locally built ones, when it sees that the online version is newer. So don’t include the snapshots repo in your project, or periodically build locally to make sure that’s most recent, to avoid that happening.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [February 27, 2020, 9:07am UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/23 "2020-02-27T09:07:42Z")

</div>

> [@tc64](#):
>
> I’m wondering, where would we add custom build flags, such as -g ?

If you want to add custom flags you can do that by setting the appropriate environment variables:

- `CMAKE_CXX_FLAGS_RELEASE` when building in release mode
- `CMAKE_CXX_FLAGS_DEBUG` when building in debug mode

If all you want is to add `-g` in order to build in debug mode, you just have to add `-Dlibnd4j.build=debug` to the maven build command.

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 27, 2020, 6:06pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/24 "2020-02-27T18:06:10Z")

</div>

Thanks Treo and AlexBlack! We greatly appreciate your help! I changed the versions in my pom file to `1.0.0-SNAPSHOT`. For some reason, its also trying to find other artifacts that I don’t believe we built. It also appears like its trying to pull this from `https://oss.sonatype.org/content/repositories/snapshots`.

Here is the full error message. I feel like I’m suppose to be specifying which architecture in my pom file somehow.

`[ERROR] Failed to execute goal on project SimpleDl4j: Could not resolve dependencies for project com.lts.simpledl4j:SimpleDl4j:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.nd4j:nd4j-native:jar:android-arm:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:android-arm64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:android-x86:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:android-x86_64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:ios-arm64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:ios-x86_64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:macosx-x86_64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:windows-x86_64:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:linux-ppc64le:1.0.0-SNAPSHOT, org.nd4j:nd4j-native:jar:linux-armhf:1.0.0-SNAPSHOT: Failure to find org.nd4j:nd4j-native:jar:android-arm:1.0.0-SNAPSHOT in https://oss.sonatype.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-nexus-snapshots has elapsed or updates are forced`

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [February 27, 2020, 6:35pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/25 "2020-02-27T18:35:00Z")

</div>

I guess you are using `nd4j-native-platform`? When building locally, you usually aren’t building for all possible platforms, but only for the one you have. For this reason you have to change to the `nd4j-native` dependency. It should pick up the correct one then.

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 27, 2020, 6:37pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/26 "2020-02-27T18:37:57Z")

</div>

Nice catch treo! Thanks!

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 27, 2020, 6:54pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/27 "2020-02-27T18:54:31Z")

</div>

I’m runnng our codebase now and I’m getting an error message. I don’t see any exception or traceback.

`==29990==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.`

The code worked just fine before, perhaps there is something I didn’t do properly while building the code?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [February 27, 2020, 6:56pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/28 "2020-02-27T18:56:27Z")

</div>

Looks like you compiled it with address sanitizer support? If you do so, you also have to load it.

See [ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD\_PRELOAD. · Issue #796 · google/sanitizers · GitHub](https://github.com/google/sanitizers/issues/796)

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 27, 2020, 7:02pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/29 "2020-02-27T19:02:19Z")

</div>

Interesting, I’ll see what I can do. I don’t think I intentially did that but probably my system’s GCC did that on its own.

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 28, 2020, 8:14pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/30 "2020-02-28T20:14:11Z")

</div>

I tried linking the libasan.so library in `LD_PRELOAD` and was still getting some weird errirs. So alternatively I tried disabling the sanitize feature from GCC. While that went successfully, it seems like building libnd4j does requre gcc to have the `-lasan` flag.

```auto
[100%] Linking CXX shared library libnd4jcpu.so
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lasan

```

I’m gonna put sanitizing back in gcc and see what I can do from there.

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [February 28, 2020, 11:47pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/31 "2020-02-28T23:47:29Z")

</div>

Hey guys, mind taking a look into this? I’m able to link the right libraries I think with the LD\_PRELOAD but it seems like there is some issue in terms of memory usage. [https://gist.github.com/zamlz/80bb11ab79b2dc0f0258862ec945dc63](https://gist.github.com/zamlz/80bb11ab79b2dc0f0258862ec945dc63)

This output kinda reminds me of valgrind output to be honest.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [February 29, 2020, 8:58am UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/32 "2020-02-29T08:58:20Z")

</div>

I guess you are using the libnd4j debug mode? when you enable that, it adds all of the following flags:  
`-g -O0 -fPIC -fmax-errors=2 -fsanitize=address`

That is what we typically use for our own debugging and hunting for memory access problems.

If you want anything other than that (like no address sanitizer) you are free to set them using the environment variable as described above. Or you can just modify the CMakeLists.txt file.

I guess you expected that only `-g` will be added with the debug flag. I apologize for wording it unclearly.

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [February 29, 2020, 10:23am UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/33 "2020-02-29T10:23:57Z")

</div>

Ye, just build in release mode, Java doesn’t play good with Asan anyway. Plus performance of debug-mode compilation is awful

---

<div class="post-metadata">

**Author:** ![zamlz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/zamlz/32/95_2.png) [@zamlz](https://community.konduit.ai/u/zamlz)\
**Post date:** [March 2, 2020, 8:08pm UTC](https://community.konduit.ai/t/build-documentation-out-of-date/180/34 "2020-03-02T20:08:29Z")

</div>

Yeah seems like it works just fine in release mode! Thanks guys! I added my flags to the `CXX` flags variable you mentioned in the post above instead.

[Previous page](https://community.konduit.ai/t/build-documentation-out-of-date/180.md?page=1)
