Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Am I able to use C++11 in QNX?

Tags:

c++

c++11

qnx

I have some cross-platform code with some C++11 features like #include <thread> and others. I will soon be using a QNX 6.6 board, and I'm wondering if my code can compile on it, and which features will be available.

QCC is the official QNX C++ compiler, but I can't find any documentation citing which C++11 features, or even which C++ features in general, it supports. Is this a wrapper around GCC or its own thing? Either way, can I get or compile other compilers on this platform?

like image 918
Laura Avatar asked Dec 09 '15 00:12

Laura


People also ask

What is a QNX C/C++ project?

QNX C/C++ Project properties For projects that use managed recursive makefiles, the build settings are defined through the UI and the IDEregenerates the makefiles whenever you change these settings. Note:In past releases, such projects were called simply QNX Projects.

How do I build libraries in QNX C/C++?

In the QNX Project wizard, you must select the project type in the Basic Settings. If you choose any type other than Application, you'll see the Librarytab in the QNX C/C++ Project properties after you've created the project. The Build target typeradio buttons let you select the kind of libraries to build.

What version of GCC does QNX use?

From what I know qcc is just using gcc internally. Because of this you can use all functionalities provided by the version of gcc that QNX decided to put into their package. The release notes provide a link to information about gcc 4.7 but I think this link better shows which specific features are supported.

How do I enable code coverage in QNX?

Also, you can enable code coverage through the Optionstab. You can access the QNX C/C++ Project properties in two ways:


Video Answer


3 Answers

From what I know qcc is just using gcc internally. Because of this you can use all functionalities provided by the version of gcc that QNX decided to put into their package.

Judging from the release notes of QNX 6.6 gcc 4.7 is used:

  • GCC 4.7 tool chain, including support for the Intel Advanced Vector Extensions (AVX)
  • GDB 7.5
  • New: Binutils 2.24
  • Python 2.7.5, as a host-side tool

The release notes provide a link to information about gcc 4.7 but I think this link better shows which specific features are supported. There is too much information on the linked page, because of that I do not copy it. But in essence the link states:

GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler option ... GCC's C++11 mode implements much of the C++11 standard produced by the ISO C++ committee

like image 188
Marged Avatar answered Sep 24 '22 09:09

Marged


Whereas @Marged's answer seems to cover absolutely every important aspect of your question, I'd like to add that it is also possible to get more current versions of all GNU dev tools (like gcc, gdb or make..). This is officially provided by the QNX staff for "experimental use only", I guess1. But so far I've had only good experiences with them.

Check out QNX's updated Core Development Tools

(You need to register to the QNX community portal first to open the link)

enter image description here

You would then update your Linux dev system like that:

  • Get files from here
    • Binutils
    • GCC
  • Extract files into a new folder (do not extract and overwrite existing folder directly since it might be that symbolic links don't get updated)
    • that should create the host and the target folder
  • Copy & paste the new files into the actual QNX folder and overwrite existing files
  • Optionally: update the config default file's value to the new compiler version
    • e.g. /../qnx650/host/linux/x86/etc/qcc/gcc/default
  • make sure 32bit libraries are installed (if not):
    • $ sudo apt-get install lib32stdc++6
    • if not installed correctly errors like the following can occur $ i486-pc-nto-qnx6.5.0-g++: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

1 Official text:"Stable versions of the Core Development Tools are included as part of QNX Momentics. You can download updated versions of these tools currently being developed through this project and benefit from their enhancements earlier!"

like image 31
Jim McAdams Avatar answered Sep 26 '22 09:09

Jim McAdams


The version of gcc that is used by qcc does support much of the C++11 specification. I've used it. Just add -std=c++11 to the compiler line.

I did find one issue with C++11 support on QNX 6.6. This was in July 2014, so things may have changed. The support of vector initialization (std::vector<int> {1,2, 3, 4};) in the C++11 library shipped with QNX 6.6 was broken. Code would compile cleanly, but then fail rather cryptically when run. Again, I don't currently know the current status of this issue, so YMMV.

like image 26
jwernerny Avatar answered Sep 24 '22 09:09

jwernerny