# QNX\_HOST environment variable not set

**URL:** https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189
**Category:** Usage
**Tags:** gen:makefiles
**Created:** [March 8, 2022, 9:00am UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189 "2022-03-08T09:00:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nenuyear](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nenuyear](https://discourse.cmake.org/u/nenuyear)
#### Post date: [March 8, 2022, 9:00am UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189/1 "2022-03-08T09:00:22Z")

</div>

I am compiling mlpack using QNX.Keep reporting the following errors:  
CMake Error at CMakeLists.txt:28 (message):QNX\_HOST environment variable not set!!!  
I have added the following to CMakeLists.txt:  
set (QNX\_HOST “/data/QNX/qnx700/host/linux”)  
set (QNX\_TARGET “/data/QNX/qnx700/target/qnx7”)  
But it still reports an error.  
Does anyone know what I should do ?

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [March 8, 2022, 5:42pm UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189/2 "2022-03-08T17:42:22Z")

</div>

If you want to set an environment variable, you need to use the `ENV{...}` syntax. See [https://cmake.org/cmake/help/latest/command/set.html#set-environment-variable](https://cmake.org/cmake/help/latest/command/set.html#set-environment-variable) for more details.

---

<div class="post-metadata">

### Author: ![nenuyear](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nenuyear](https://discourse.cmake.org/u/nenuyear)
#### Post date: [March 9, 2022, 2:18am UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189/3 "2022-03-09T02:18:58Z")

</div>

I have added the following content to CMakeLists.txt, but still report an error–“error: environment variables QNX\_HOST and QNX\_TARGET not defined”:

set(QNX\_HOST “$ENV{QNX\_HOST}”)  
set(QNX\_TARGET “$ENV{QNX\_TARGET}”)  
message(STATUS “_**")  
message(STATUS “${QNX\_HOST}”)  
message(STATUS “${QNX\_TARGET}”)  
message(STATUS "**_”)  
#Check environment variables  
if ("$ENV{QNX\_HOST}" STREQUAL “”)  
#message(FATAL\_ERROR “QNX\_HOST environment variable not set”)  
endif()

if ("$ENV{QNX\_TARGET}" STREQUAL “”)  
#message(FATAL\_ERROR “QNX\_TARGET environment variable not set”)  
endif()

And I also have set “source /etc/bash.bashrc\_qnx qnx\_aarch64”.

---

<div class="post-metadata">

### Author: ![nenuyear](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@nenuyear](https://discourse.cmake.org/u/nenuyear)
#### Post date: [March 9, 2022, 3:16am UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189/4 "2022-03-09T03:16:37Z")

</div>

This bug has not been solved yet, which is described in more detail.[qnx - QNX\_HOST environment variable not set - Stack Overflow](https://stackoverflow.com/questions/71392941/qnx-host-environment-variable-not-set)

---

<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: [March 10, 2022, 3:53am UTC](https://discourse.cmake.org/t/qnx-host-environment-variable-not-set/5189/5 "2022-03-10T03:53:32Z")

</div>

The toolchain must be set up outside of CMake; CMake cannot make environment settings available during the build for every generator, so it doesn’t provide such support. See [this thread](https://discourse.cmake.org/t/cmake-environment-variables-for-qnx-toolchain/4778) for more discussion of this.
