QNX_HOST environment variable not set

3.2k views Asked by At

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”)

I first executed the following command:

source /etc/bash.bashrc_qnx qnx_aarch64
source /data/QNX/qnx700/qnxsdp-env.sh

=>

QNX_HOST=/data/QNX/qnx700/host/linux/x86_64
QNX_TARGET=/data/QNX/qnx700/target/qnx7
MAKEFLAGS=-I/data/QNX/qnx700/target/qnx7/usr/include

And cmake .. But sudo make command still report an error–“error: environment variables QNX_HOST and QNX_TARGET not defined”.The following is the content of part document CMakeLists.txt:

set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_HOST_SYSTEM_NAME QNX)
set(QNX_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 7.0.0)
set(CMAKE_CROSSCOMPILING 1)
set( TOOLCHAIN QNX )
set(CMAKE_SYSROOT "$ENV{TOOLCHAIN_PATH}")
#set (QNX_HOST "/data/QNX/qnx700/host/linux")
#set (QNX_TARGET "/data/QNX/qnx700/target/qnx7")
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()
set(CMAKE_C_COMPILER "/data/QNX/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-gcc")
set(CMAKE_CXX_COMPILER "/data/QNX/qnx700/host/linux/x86_64/usr/bin/aarch64-unknown-nto-qnx7.0.0-g++")
#set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++")
set(CMAKE_CXX_STANDARD 14) # C++14...
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS ON) #...without compiler extensions like gnu++14
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

When I running make without sudo, it still report an error–-

[ 10%] Linking CXX executable ../../bindings/julia/mlpack/build/bin/generate_jl_sparse_coding
../../../../lib/libmlpack.so.3.4: undefined reference to `dpotrf_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dpotri_'
../../../../lib/libmlpack.so.3.4: undefined reference to `ddot_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgbsvx_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgeqrf_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dposvx_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgemm_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgesdd_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgels_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dnrm2_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dlansy_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dpotrs_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dtrcon_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgesv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dsyevd_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgbcon_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgbtrs_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dposv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgetri_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgemv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgesvd_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgbtrf_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dlange_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dtrtrs_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgecon_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dlangb_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dsyrk_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgetrf_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgesvx_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dpbtrf_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgetrs_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgelsd_'
../../../../lib/libmlpack.so.3.4: undefined reference to `ilaenv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dsyev_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgbsv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dorgqr_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dtrtri_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dgtsv_'
../../../../lib/libmlpack.so.3.4: undefined reference to `dpocon_'
collect2: error: ld returned 1 exit status
src/mlpack/methods/sparse_coding/CMakeFiles/generate_jl_sparse_coding.dir/build.make:119: recipe for target 'src/mlpack/bindings/julia/mlpack/build/bin/generate_jl_sparse_coding' failed
make[2]: *** [src/mlpack/bindings/julia/mlpack/build/bin/generate_jl_sparse_coding] Error 1
CMakeFiles/Makefile2:6388: recipe for target 'src/mlpack/methods/sparse_coding/CMakeFiles/generate_jl_sparse_coding.dir/all' failed
make[1]: *** [src/mlpack/methods/sparse_coding/CMakeFiles/generate_jl_sparse_coding.dir/all] Error 2
Makefile:145: recipe for target 'all' failed

Does anyone know what should I do ?

1

There are 1 answers

4
Will Miles On

You need to ensure that you've added the QNX build toolchain to your environment. QNX provides the 'qnxsdp-env.sh' shell script (or qnx-sdp-env.bat for Windows) to set up the toolchain. This will set all appropriate environment variables. Run this script before trying to use any other build commands such as cmake, make, qcc, etc.

Inferring from your example that you're using QNX 7.0 on a Linux host, try:

$ source /data/QNX/qnxsdp-env.sh
$ cmake

Note that source is important: it instructs the shell to run the script such that it can modify the current shell environment, rather than launching it in a subshell. If you run the script without source, the script will have no effect.

Reference: http://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.prog/topic/devel_OS_version.html