# In Cxx, how to supply compiler flags like -O2 or --std==c++17

**URL:** <https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435>\
**Category:** General Usage\
**Tags:** cxx\
**Created:** [January 16, 2020, 7:21am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435 "2020-01-16T07:21:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JJB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jjb/32/6773_2.png) [@JJB](https://discourse.julialang.org/u/JJB)\
**Post date:** [January 16, 2020, 7:21am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435/1 "2020-01-16T07:21:06Z")

</div>

When using the Cxx package, how can I supply flags to Clang like -O2 or --std==c++17?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [January 16, 2020, 7:28am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435/2 "2020-01-16T07:28:06Z")

</div>

I don’t think Cxx is a compiler like `gcc` so this doesn’t make sense?

edit: maybe one can use the “Compiling into shared library” described on github README

---

<div class="post-metadata">

**Author:** ![JJB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jjb/32/6773_2.png) [@JJB](https://discourse.julialang.org/u/JJB)\
**Post date:** [January 16, 2020, 7:30am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435/3 "2020-01-16T07:30:43Z")

</div>

It’s still compiling the code, so at some stage it must pick an optimisation level and C++ version. Issue came up because I tried to cxxinclude some C++17 code and it failed as if --std=c++17 wasn’t enabled.

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [January 16, 2020, 10:54am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435/4 "2020-01-16T10:54:28Z")

</div>

I guess you could edit the following line and do a source build.

[https://github.com/JuliaInterop/Cxx.jl/blob/14c403a58ba0bec12e9893a3acf0b28dfc8ffa3a/src/bootstrap.cpp#L1447](https://github.com/JuliaInterop/Cxx.jl/blob/14c403a58ba0bec12e9893a3acf0b28dfc8ffa3a/src/bootstrap.cpp#L1447)

---

<div class="post-metadata">

**Author:** ![JJB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jjb/32/6773_2.png) [@JJB](https://discourse.julialang.org/u/JJB)\
**Post date:** [January 18, 2020, 8:59am UTC](https://discourse.julialang.org/t/in-cxx-how-to-supply-compiler-flags-like-o2-or-std-c-17/33435/5 "2020-01-18T08:59:39Z")

</div>

Thanks!
