Am I able to use C++11 in QNX?
Asked Answered
T

3

8

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?

Tonneson answered 9/12, 2015 at 0:2 Comment(2)
Does your Airforce one use QNX ? ;-) As far as I know qcc is just using gcc and because of this it depends which gcc is used by QNX 6.6. A quick search shows that QNX 6.6 is using gcc 4.7 (qnx.com/developers/articles/rel_5849_7.html) and here is a list of supported features of gcc 4.7: gcc.gnu.org/projects/cxx0x.htmlPollitt
@Pollitt I'd answerate that one. It's about as good as anyone is going to get for this question.Divvy
P
11

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

Pollitt answered 9/12, 2015 at 6:46 Comment(1)
qcc is just using gcc internally.. 7 years later. Does it still valid?Longer
N
7

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!"

Noach answered 24/1, 2016 at 12:43 Comment(2)
I have problem only with that: QtCore/qglobal.h:39: error: cstddef: No such file or directory # include <cstddef> any idea? When switching to 4.6.3 (default previous) all okPalaeontography
Sounds more like your QT environment isn't installed and configured correctly (Qt Creator). Are you perhaps using MS Visual Studio? TBH, I haven't used QT yet in combination with the QNX dev environment, so I won't be much of a help here.Noach
L
5

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.

Lamphere answered 9/12, 2015 at 13:43 Comment(1)
I can confirm this. QNX 6.6 list initialization is still broken. The code will just get stuck. I have searched around and this is the only place I've seen people complained about this.Cupric

© 2022 - 2024 — McMap. All rights reserved.