Building Cantera libraries for QNX

134 views
Skip to first unread message

Roberto Paolinelli

unread,
Jan 11, 2022, 4:10:37 AM1/11/22
to Cantera Users' Group
Hello,
I would like to use Cantera library both in Simulink and in hardware in the loop with Speedgoat target machine running with QNX OS.
As far as I know new matlab interface is not ready and it has less functionalities than C++, so I'm trying to use Cantera C++ and use legacy code to use i in Simulink.
So far in simulation properly works, but problems arise when I want to make it run on speedgoat target machine for hardware in the loop, because I need Cantera and Boost libraries built for QNX.

Does anyone know how o make it? 

Thank you very much
Roberto

Ray Speth

unread,
Jan 11, 2022, 11:24:17 AM1/11/22
to Cantera Users' Group
Hi Roberto,

I don't know anything about QNX or Speedgoat beyond what a quick Google search could tell me, but I think what you would need to do is cross-compile the Cantera library, where you use your (Linux/Windows) computer to compile code that will run on the QNX machine. Presumably they provide some sort of SDK with a compiler that can do this. Cantera only uses the header-only portions of Boost, so there's no need to compile anything on that front. Just having those headers available on the machine where you're compiling Cantera would be sufficient. For Cantera's other dependencies (Sundials, yaml-cpp, libfmt), if you use the Git submodules, those will all be compiled as part of the Cantera compilation process, so that should give you everything you need to use the Cantera C++ library on this target.

Regards,
Ray

Roberto Paolinelli

unread,
Jan 11, 2022, 11:49:44 AM1/11/22
to canter...@googlegroups.com
Hi Ray,
thank you very much for your kind and quick reply.
Yes I need to cross compile the library.
Speedgoat target machine is a PC-like machine with a real time OS inside making run a Simulink model for rapid prototyping and/or hardware in the loop purposes.
At the moment I don't have any SDK, I have just noticed QNX is launched during the build phase of the generated C++ code for speedgoat.
As far as I understand I can either build separately the Cantera library (but I don't know how to get compiler for QNX standalone) or specify all Cantera cpp sources and make a unique executable file in Simulink.

One question: if I clone the repo from https://github.com/Cantera/cantera, do I get all submodules too? Or how can I get them?  
--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/RQiMHcgdvYY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cantera-users/907e3a05-a2d0-43fe-8d31-a08dfe031261n%40googlegroups.com.


--
Ing. Roberto Paolinelli
Electronics Engineering & Consulting
P.IVA (Vat Number): IT 02643190420

Bryan Weber

unread,
Feb 5, 2022, 8:17:53 AM2/5/22
to Cantera Users' Group
Hi Roberto,

If you specify


Then it will clone all the submodules as well. If you already have copy cloned on your computer, you can run (from inside the cantera directory)

git submodule update --init --recursive

to clone the submodules.

Best,
Bryan

Roberto Paolinelli

unread,
Feb 9, 2022, 11:27:01 AM2/9/22
to canter...@googlegroups.com
Hello Bryan
thanks a lot.
Best Regards
Roberto

Roberto Paolinelli

unread,
Feb 9, 2022, 12:05:16 PM2/9/22
to canter...@googlegroups.com
Hello,
is there an already developed makefile to build Cantera cpp source code?

If so, I should only point to the QNX compiler (e.g. qcc) and linker and change some options...

Am I right?
Thank you very much
Best Regards
Roberto



Il giorno sab 5 feb 2022 alle ore 14:17 Bryan Weber <bryan....@gmail.com> ha scritto:

Ingmar Schoegl

unread,
Feb 11, 2022, 10:08:36 AM2/11/22
to Cantera Users' Group
Ciao Roberto,
The sample folders contain Makefiles for cxx compilation, so you should be able to use those as a template. For these to work, there is one central file summarizing the compilation environment in the installed
<path_to_headers>/include/cantera/Cantera.mak
Hope this helps,
-ingmar-

Roberto Paolinelli

unread,
Feb 15, 2022, 4:15:00 AM2/15/22
to canter...@googlegroups.com
Hello Ingmar,
thank you very much for your reply.

I'm sorry but either I haven't fully understood what you mean or my explanation about the request is poor.

I need to build the whole Cantera library source code for QNX (QCC compiler).

Moreover please consider I can build from makefile with GCC and nothing more than this... :(
So I need some more help from you or he Community

On the one hand the only makefiles "like" I have found are:
  1. Cantera.mak.in
  2. Makefile.in
Are they bare template?
Why .in extension in those files?
What does the construct @some_text@ stand for? Is it a template?

On the other hand I have found a SConscript and Cantera website reports using scons (I don't know it), but I haven't found how to configure it to use another compiler/linker.

Can you help me with this?

Thanks a lot.
Best Regards
Roberto




Ingmar Schoegl

unread,
Feb 15, 2022, 5:19:53 PM2/15/22
to Cantera Users' Group
Ciao Roberto,

Ok, that clarifies things for me a little. You guessed correctly: the files with extension '.in' are templates, and will get filled in by Cantera's build process (i.e. you can use those for building custom code once everything is compiled). That said, the entire build process depends heavily on SCons: are you able to use that on your system? (this will also require a Python installation etc.). If your system supports SCons, then the way forward would be to follow a regular 'compilation from source' routine (which may or may not work without tweaks, as QNX is not an environment that is tested). Otherwise, things may get complicated.

-ingmar-  

Roberto Paolinelli

unread,
Feb 16, 2022, 2:25:23 AM2/16/22
to canter...@googlegroups.com
Hello Ingmar,
thanks for your reply.
I have never tried to build from SCons but I guess it might be my first time: I have Python installed so that's not a problem.
One question: as I need to cross compile, where can I instruct SCons to find the path for C, C++ compilers and linker executables?

On the other hand I think the only alternative is to type my own makefile.

Thanks a lot for your feedback

Best Regards
Roberto



Ray Speth

unread,
Feb 16, 2022, 12:37:48 PM2/16/22
to Cantera Users' Group
Hi Roberto,

All of the configuration options for SCons are documented here: https://cantera.org/compiling/config-options.html. The two options you're looking for are `CC` and `CXX`. SCons should generally rely on the C++ compiler to call the linker itself.

Regards,
Ray

Roberto Paolinelli

unread,
Feb 22, 2022, 4:53:00 AM2/22/22
to canter...@googlegroups.com
Hello Ray,
I have tried to launch QCC and Q++ setting their path informations in CC and CXX but it didn't work.

When I type scons build providing CC, CXX and boost_inc_dir 

C:\cantera>scons build boost_inc_dir=C:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\target\qnx7\usr\include\boost CC=C:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\host\win64\x86_64\usr\bin\qcc.exe CXX=C:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\host\win64\x86_64\usr\bin\q++.exe

I get he following error message

file C:\cantera\SConstruct,line 1016:
Configure(confdir = .sconf_temp)
scons: Configure: Checking for C++ header file cmath...
scons: Configure: ".sconf_temp\conftest_4501b9bf892a8ba32d6185db437667f6_0.cpp" is up to date.
scons: Configure: The original builder output was:
  |.sconf_temp\conftest_4501b9bf892a8ba32d6185db437667f6_0.cpp <-
  |  |
  |  |#include <cmath>
  |  |
  |  |
  |
C:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\host\win64\x86_64\usr\bin\q++.exe /Fo.sconf_temp\conftest_4501b9bf892a8ba32d6185db437667f6_0_00d12a0649b885c77ba20f3a874d07db.obj /c .sconf_temp\conftest_4501b9bf892a8ba32d6185db437667f6_0.cpp -std=c++11 -O3 -g /DNDEBUG /IC:\ProgramData\MATLAB\SupportPackages\R2021b\toolbox\slrealtime\target\supportpackage\qnx710\target\qnx7\usr\include\boost
cc: The QNX_HOST/QNX_TARGET environment variables must be set
scons: Configure: no

Those variables are in the reported batch file (Google doesn't allow me to attach it for safety reasons) I have launched in the same shell window before launching scons build process.
Here's qnxsdp-env.bat listing (there's also the .sh version for Linux)

@echo off
REM This script sets environment variables required to use this version of QNX Software Development Platform
REM from the command line. To use this script execute it in windows command shell (cmd).

set QNX_BASE=%~dp0

@echo on

set QNX_BASE=%QNX_BASE:\=/%
set QNX_TARGET=%QNX_BASE%/target/qnx7
set QNX_HOST=%QNX_BASE%/host/win64/x86_64

set QNX_CONFIGURATION_EXCLUSIVE=%USERPROFILE%/.qnx
set QNX_CONFIGURATION=%QNX_CONFIGURATION_EXCLUSIVE%

set MAKEFLAGS=-I%QNX_TARGET%/usr/include
set PATH=%QNX_HOST%/usr/bin;%QNX_BASE%/jre/bin;%QNX_BASE%/host/common/bin;%PATH%

@REM This is set to make sdp installation read-only (otherwise python will create extra files when you run debuger)
@REM If you using python for something else and need it, comment out this line
set PYTHONDONTWRITEBYTECODE=1

set TMPDIR=%TMP%

@set LICENSE_SCRIPT=%QNX_BASE%\license-env.bat
if exist %LICENSE_SCRIPT% %LICENSE_SCRIPT%

@echo on
REM Checking license
set QNX_LICENSE_FILE_LOCATION=%QNX_CONFIGURATION:/=\%\license\
set QNX_LICENSE_FILE=%QNX_LICENSE_FILE_LOCATION%licenses
set QNX_LICENSE_SOURCE_FILE=%QNX_BASE:/=\%license\licenses
IF NOT EXIST %QNX_LICENSE_FILE% (
xcopy %QNX_LICENSE_SOURCE_FILE% %QNX_LICENSE_FILE_LOCATION% /s /i /Y
)
@echo on

@REM Do not edit past this line

I think I need to make those variables visible to QNX inside the scons build process, but how can I do that?

Thanks a lot
Best Regards
Roberto

Ingmar Schoegl

unread,
Feb 22, 2022, 8:32:25 AM2/22/22
to Cantera Users' Group
Hi Roberto,

You should be able to use the ‘env_vars’ option. Overall, the scons build is highly configurable, see https://cantera.org/compiling/config-options.html#scons-config

-ingmar-

Roberto Paolinelli

unread,
Feb 22, 2022, 8:58:20 AM2/22/22
to canter...@googlegroups.com
Hello Ingmar
thanks a lot
I'll take a look a be back to you asap

Thank you very much
Roberto

Reply all
Reply to author
Forward
0 new messages