03-26-2019 09:42 AM
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.
03-26-2019 10:04 AM
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- .
03-26-2019 01:46 PM
Thanks. That worked but now I get an error saying
mosquittopp.cpp:17:19: fatal error: cstdlib: No such file or directory
#include <cstdlib>
03-26-2019 01:55 PM
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.
03-27-2019 08:19 AM - edited 03-27-2019 08:36 AM
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
03-27-2019 08:40 AM
I am making some progress with CC=gcc.
03-27-2019 09:55 AM
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.
03-27-2019 09:59 AM
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.
03-27-2019 10:28 AM
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.
03-27-2019 01:18 PM
This is the build instructions from the readme.md
I'll take a look at it again and see if I misunderstood something.
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.
make WITH_SRV=no
make WITH_UUID=no
make WITH_WEBSOCKETS=yes
make WITH_TLS=no
make WITH_DOCS=no