# How to globally set extra linker option like -lstdc++fs

**URL:** https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842
**Category:** Usage
**Created:** [August 30, 2023, 9:19am UTC](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842 "2023-08-30T09:19:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![G\_T](https://discourse.cmake.org/user_avatar/discourse.cmake.org/g_t/32/3761_2.png) [@G\_T](https://discourse.cmake.org/u/G_T)
#### Post date: [August 30, 2023, 9:19am UTC](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842/1 "2023-08-30T09:19:03Z")

</div>

I’m trying to build some third-party software which is failing as I’m using gcc8. I have to pass `-lstdc++fs` as linker option.  
I cannot change cmake files so I would like to know if there is a way to set extra linker options as environment variable so it will be used if there are more than on cmake call.

Thank you

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [August 30, 2023, 9:43am UTC](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842/2 "2023-08-30T09:43:16Z")

</div>

Take a look at [LDFLAGS](https://cmake.org/cmake/help/latest/envvar/LDFLAGS.html) and various `CMAKE_*_LINKER_FLAGS_INIT` variables.

---

<div class="post-metadata">

### Author: ![G\_T](https://discourse.cmake.org/user_avatar/discourse.cmake.org/g_t/32/3761_2.png) [@G\_T](https://discourse.cmake.org/u/G_T)
#### Post date: [August 31, 2023, 3:30pm UTC](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842/3 "2023-08-31T15:30:25Z")

</div>

I can export LDFLAGS from commandline but linker is still failing because of the order in which `-lstdc++fs` appears.  
I want to `-lstdc++fs` to go at the end
