NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

g++: Command not Found

Highlighted

Hello,

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 oecore-x86_64-core2-64-toolchain-5.0.sh 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
(1,290 Views)
Highlighted

Briefly looking over the Mosquito's Makefiles (e.g. https://github.com/eclipse/mosquitto/blob/master/lib/Makefile#L92), 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
(1,283 Views)
Highlighted

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
(1,260 Views)
Highlighted

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
(1,258 Views)
Highlighted

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
(1,249 Views)
Highlighted

I am making some progress with CC=gcc. 

0 Kudos
Message 6 of 13
(1,245 Views)
Highlighted

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
(1,241 Views)
Highlighted

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 config.mk (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 config.mk now and fix those problems.

0 Kudos
Message 8 of 13
(1,239 Views)
Highlighted

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
(1,232 Views)
Highlighted

This is the build instructions from the readme.md

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 http://mosquitto.org/download/.

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

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
(1,226 Views)