NI Linux Real-Time Discussions

Showing results for 
Search instead for 
Did you mean: 

g++: Command not Found



I am trying to install mosquitto broker on a cRIO-9030. 

If I use the command opkg install mosquitto, I get a response saying Couldn't find anythign to satisfy mosquitto. 

So I switched to trying to compile mosquitto from mosquitto-1.5.8.tar.gz. I can also install it from git source code repository, but both should work.

I am building the tar.gz file on a virtual machine Ubuntu 18.01.1 LTS. 

When I run

make WITH_UUID=no WITH_websockets=yes WITH=TLS=no

in the mosquitto directory, I get an error g++: command not found.

I installed to the directory above mosquitto, but that didn't fix the issue.

which gcc responds with /usr/bin/gcc

but i get nothing back when i run which g++. 

I think i can cross compile this from windows using eclipse c/c++, but this method should work too. 


0 Kudos
Message 1 of 13

Briefly looking over the Mosquito's Makefiles (e.g., it seems like you need to define CROSS_COMPILE to something like /path/to/sysroots/x86_64-nilrtsdk-linux/usr/bin/x86_64-nilrt-linux/x86_64-nilrt-linux- .


Message 2 of 13

Thanks. That worked but now I get an error saying 

mosquittopp.cpp:17:19: fatal error: cstdlib: No such file or directory

 #include <cstdlib>

0 Kudos
Message 3 of 13

The toolchain you installed provides headers for common libraries like glibc at /path/to/sysroots/x86_64-nilrt-linux/usr/include/ . You'll need to pass some arguments to cc/gcc/g++/etc to add this directory to the search path. Consult gcc documentation for exact flags to use. You should be able to pass these options to Mosquito by setting the LIB_CFLAGS variable.


0 Kudos
Message 4 of 13

Thanks for the quick response.

The only thing in /path/to/sysroots/x86_64-nilrt-linux/usr/include/ is a python2.7 folder which wouldn't contain the c++ folder. However I did find c++ headers in /path/to/sysroots/core2-64-nilrt-linux/usr/include/c++/4.9.2/. But that didn't work. I am not 100% sure I set up my make command correctly. 

In the documentation I had a hard time telling the difference between what the command should be in the make file (which I don't want to edit), in the c++ code, or if it is in the make command.

So my make command was

make [WITH_UUID.... all the stuff I wrote above] -I  /path/to/sysroots/core2-64-nilrt-linux/usr/include/c++/4.9.2/

But I am not confident with this or if I should just point to the include folder and not all the way to c++. It is also possible I'm way off base here too.


I am playing with the syntax to get it correct and I put in make .... LIB_CFLAGS=-I/path/to/sysroots/core2-64-nilrt-linux/usr/include/c++/4.9.2/ I get a new error.

IT says /path/to/sysroots/x86_64-nilrtsdk-linux/usr/bin/x86_64-nilrt-linux/x86_64-nilrt-linux-cc: Command not found

0 Kudos
Message 5 of 13

I am making some progress with CC=gcc. 

0 Kudos
Message 6 of 13

You might consider simply setting --sysroot and --isysroot to /path/to/sysroots/core2-64-nilrt-linux/ . (g)cc and it's ld should figure out the details with those two breadcrumbs, like which set of /usr/include/... subdirs to search for header. That might be easier than constructing compiler and linker search paths yourself. However, I have not tested this and I'm not completely sure it'll work.


0 Kudos
Message 7 of 13

I'll have to look into that, but right now how I am constructing it seems to be moving me forward. 


My current error says

config.h: No such file or directory

 #include "config.h"


So I am looking into this. I saw somewhere say I should have ran (which I didn't do) because it throws a lot of errors like 

WITH_TLS_PSK:=yes: command not found


But I guess I have to run now and fix those problems.

0 Kudos
Message 8 of 13

Using generated code (config headers, makefiles, etc) is fairly common workflow in many projects. There's no clear standard for doing this. Autotools is one of the more widely used build systems out there. It seems this project rolled their own. In any case, the workflow is fairly ubiquitous and is exactly what you observed.. first run a script (or sometimes multiple scripts) to configure the source then run `make`. I highly recommend reading over build instructions to figure out their configuration process, then modify it as needed for cross compile.


0 Kudos
Message 9 of 13

This is the build instructions from the

I'll take a look at it again and see if I misunderstood something.

Building from source

To build from source the recommended route for end users is to download the archive from

On Windows and Mac, use cmake to build. On other platforms, just run make to build. For Windows, see also

If you are building from the git repository then the documentation will not already be built. Use make binary to skip building the man pages, or install docbook-xsl on Debian/Ubuntu systems.

Build Dependencies

  • c-ares (libc-ares-dev on Debian based systems) - disable with make WITH_SRV=no
  • libuuid (uuid-dev) - disable with make WITH_UUID=no
  • libwebsockets (libwebsockets-dev) - enable with make WITH_WEBSOCKETS=yes
  • openssl (libssl-dev on Debian based systems) - disable with make WITH_TLS=no
  • xsltproc (xsltproc and docbook-xsl on Debian based systems) - only needed when building from git sources - disable with make WITH_DOCS=no
0 Kudos
Message 10 of 13