# cross-compiling with CMake

**URL:** <https://openmc.discourse.group/t/cross-compiling-with-cmake/97>\
**Category:** User Support\
**Created:** [July 29, 2014, 11:03pm UTC](https://openmc.discourse.group/t/cross-compiling-with-cmake/97 "2014-07-29T23:03:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronald\_Rahaman](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ronald\_Rahaman](https://openmc.discourse.group/u/Ronald_Rahaman)\
**Post date:** [July 29, 2014, 11:03pm UTC](https://openmc.discourse.group/t/cross-compiling-with-cmake/97/1 "2014-07-29T23:03:16Z")

</div>

Hi all,

Does OpenMC v0.6.0 have support for cross-compilation environments? If not, do you have any suggestions for setting up cross-compilation with Cmake?

Right now, when I try to compile on BG/Q, cmake is auto-detecting the wrong compiler (it’s detecting the compiler for the login node). I’m considering setting up some toolchains, as described here ([http://www.cmake.org/Wiki/CMake\_Cross\_Compiling](http://www.cmake.org/Wiki/CMake_Cross_Compiling)), but I don’t have any experience with it and any suggestions would be appreciated.

Thanks and best wishes,  
Ron Rahaman

---

<div class="post-metadata">

**Author:** ![smharper](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@smharper](https://openmc.discourse.group/u/smharper)\
**Post date:** [July 30, 2014, 7:37am UTC](https://openmc.discourse.group/t/cross-compiling-with-cmake/97/2 "2014-07-30T07:37:30Z")

</div>

Greetings,

You can tell CMake which compiler you want to use by setting the “FC” environment variable. For example, see [http://mit-crpg.github.io/openmc/usersguide/install.html#compiling-with-mpi](http://mit-crpg.github.io/openmc/usersguide/install.html#compiling-with-mpi)

Sterling

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 30, 2014, 3:49pm UTC](https://openmc.discourse.group/t/cross-compiling-with-cmake/97/3 "2014-07-30T15:49:03Z")

</div>

Hi Ron,

I don’t think anyone has tried cross-compilation environments in any serious effort. I did once make a feeble attempt to cross compile for Windows with mingw on a Linux machine – it didn’t work on the first try, and I didn’t care that much so I gave up.

As Sterling suggested, you should be able to set the compiler explicitly using FC. That should solve your current woes on BG/Q, although I would consider that separate from a discussion of cross-compilation.

Paul

---

<div class="post-metadata">

**Author:** ![Ronald\_Rahaman](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ronald\_Rahaman](https://openmc.discourse.group/u/Ronald_Rahaman)\
**Post date:** [July 30, 2014, 4:03pm UTC](https://openmc.discourse.group/t/cross-compiling-with-cmake/97/4 "2014-07-30T16:03:59Z")

</div>

Thanks, guys! I will use Sterling’s suggestion as a quick fix, and I will look into cross-compilation toolchains as a long-term solution. Looks like this issue has been addressed for other projects here at ANL ( [https://wiki.alcf.anl.gov/parts/index.php/Mira\_Build\_System\_Software\_Documentation](https://wiki.alcf.anl.gov/parts/index.php/Mira_Build_System_Software_Documentation) ), so I should be able to hunt down some experts.
