# cannot link to dynamic library during parallel build

**URL:** <https://discourse.cmake.org/t/cannot-link-to-dynamic-library-during-parallel-build/1685>\
**Category:** Usage\
**Tags:** os:linux, gen:ninja\
**Created:** [August 10, 2020, 9:53am UTC](https://discourse.cmake.org/t/cannot-link-to-dynamic-library-during-parallel-build/1685 "2020-08-10T09:53:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy-lcq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sandy-lcq](https://discourse.cmake.org/u/sandy-lcq)\
**Post date:** [August 10, 2020, 9:53am UTC](https://discourse.cmake.org/t/cannot-link-to-dynamic-library-during-parallel-build/1685/1 "2020-08-10T09:53:25Z")

</div>

I met a compile fail problem, which is caused by parallel build. Please see this bug report for detail:  
[https://bugs.llvm.org/show\_bug.cgi?id=46617](https://bugs.llvm.org/show_bug.cgi?id=46617)

how can I fix this in CMakeList.txt? I have explicitly change target\_link\_libraries to .so, but during parallel build, if .a is generated first, it is possbile that .a is used, and make the build fail, is this bug of cmake?

Thanks

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 11, 2020, 9:16pm UTC](https://discourse.cmake.org/t/cannot-link-to-dynamic-library-during-parallel-build/1685/2 "2020-11-11T21:16:40Z")

</div>

It seems like the build graph is not well-defined if this can happen. Inside of CMake code, using the target names rather than `-L/path -llibname` would avoid any confusion like this. I’m not sure how the ambiguous command line ends up appearing though.

---

<div class="post-metadata">

**Author:** ![sandy-lcq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sandy-lcq](https://discourse.cmake.org/u/sandy-lcq)\
**Post date:** [November 17, 2020, 2:19am UTC](https://discourse.cmake.org/t/cannot-link-to-dynamic-library-during-parallel-build/1685/3 "2020-11-17T02:19:13Z")

</div>

thanks. this seems decide by gcc link order, and build graph. so I will close this issue.
