How to compile C++ file on Wind River Workbench 3.3 ? - vxworks

I try to compile C++ file on Wind River Workbench 3.3 , report error (etoa:4020): identifier "class" is undefined.
I have modified build tools to c++ compiler ,it still doesn't work .
error
build option

Related

CMake knows std 20, but g++9 doesn't

I have a project, which cannot be compiled by a fellow, due to an unknown call to a method from the std library.
I suspect that it's due to the fellow's g++ version (9.4.2) because the function was added in the std 20 standard. To test if that is the case I installed g++-9 (Version 9.5.0) and pointed the /usr/bin/g++ symbolic link to g++-9 and stumbled upon another issue (the question).
When I run
$ g++-9 -std=c++20
g++-9: error: unrecognized command line option ‘-std=20’; did you mean ‘-std=c2x’?
g++-9: fatal error: no input files
compilation terminated.
I get an error stating, that the std standard version 20 is unknown.
But when I try to generate the build files for an cmake project with the following line in the CMakeLists.txt:
target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_20
)
I get no error. But when replacing the 20 with a 23:
target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_23
)
I get the error
CMake Error at CMakeLists.txt:74 (target_compile_features):
target_compile_features The compiler feature "cxx_std_23" is not known to
CXX compiler
"GNU"
version 9.5.0.
Why is the C++20 standard unknown to g++, but known, when generating build files with cmake?
This is some sort of follow up Question:
When I try to compile my project I get the error:
error: ‘std::stringstream’ {aka ‘class std::__cxx11::basic_stringstream<char>’} has no member named ‘view’
and view was added in c++20. Can it be, that view was jet not added in c++2a?
Well... if your compiler is GCC 9.5.0, the reason why CMake says it doesn't know about C++23 is because... it doesn't?
https://en.cppreference.com/w/cpp/compiler_support
The only thing that cppreference.com's compiler support table says that GCC v9 "knows" about C++23 is "Narrowing contextual conversions in static_assert and constexpr if"
And the reason why you get "g++-9: error: unrecognized command line option ‘-std=20’; did you mean ‘-std=c2x’?" for GCC 9.5.0 is probably just because C++20 support wasn't fully implemented yet. Again, look at the compiler support table in cppreference.com. There are lots of core language features and library features for C++20 that GCC didn't implement until version 10 (some even in version 9-13 Ex. "Atomic Compare-And-Exchange with padding bits")
So just do what it told you to do and take what you get, accepting that not all of the C++20 features will be available in GCC 9.5.0.
Or upgrade you compiler :P
The reason why it works with CMake's target_compile_features(... cxx_std_20) is because... CMake handles it.
See Modules/Compiler/GNU-C.cmake:
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 9.1)
set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x")
set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x")
endif()
and Modules/Compiler/GNU-CXX.cmake:
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
endif()
The name of the option for standard C++20 up to GCC 9 is -std=c++2a. According to man gcc:
c++2a
The next revision of the ISO C++ standard, planned for 2020. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.
So not all features can be expected to be in there.
GCC has a tradition of providing aliases for the not yet released standards or those with incomplete support. GCC 9 only knows c++2a and that became an alias for c++20 with GCC 10.
CMake can handle this. When in doubt what CMake uses as standard (or any other option), take a look in the build directory in flags.make or build.ninja (depending on which generator you're using).

Compile ANTLR4 runtime with GCC/MinGW

I am trying to compile the ANTLR4 runtime sources
with GCC compiler and MinGW libraries. Is that
possible.
My development environment :
Windows 10, CodeBlocks, GCC, MinGW libraries
Compilation stops with the following error :
error: 'mutex' in namespace 'std' does not name a type
Kind regards
Pier Tilma
The MinGW version that comes with Code::Blocks us much too old.
Use a more up to date version of MinGW-w64.
For example the one from: https://winlibs.com/ (instructions for Code::Blocks are on the site).
Thanks Sanders,
Using an up-to-date MingW version doesn't give me anymore the
error: 'mutex' in namespace 'std' does not name a type.
But now I ran into another problem :
When crosscompiling the ANTLR4 runtime sources for windows on Linux I
get the following error :
/src/atn/ATNSimulator.cpp:17:21: error: definition of static data member ‘antlr4::atn::ATNSimulator::ERROR’ of dllimport’d class
My configuration :
os : Ubuntu (Linux 5.15.0-52-generic x86_64),
compiler : x86_64-w64-mingw32-gcc (9.3 posix),
antlr4 : runtime sources 4.11.1
Regards pstilma

qt5 build with cmake on window: ERROR: C++11 <random> is required and is missing or failed to compile

My env:
Qt source: dev branch
cmake version: 3.18.4.0
os: windows
Build step:
cd qt_source
mkdir build
cd build
cmake -DMAKE_BUILD_TYPE=Release ..
Then error raised:
ERROR: C++11 <random> is required and is missing or failed to compile.
ERROR: detected a std::atomic implementation that fails for function pointers. Please apply the patch corresponding to your Standard Library vendor, found in qtbase/config.tests/atomicfptr
How can I debug this?
Update on 2020/10/26:
I used the vcpkg install qt5 and it works.
I'd recommend you to use a bit more stable Qt branch, e.g. 5.15.1 or 5.12, otherwise you should be aware that dev branch is on-going development of new features and Qt 6 (as of 01/11/2019), and all bug fixes that are not only relevant for Qt 5 (as of 15/05/2020).
From my practical experience, current dev branch always need some tricks to use and brings lots of problems. If you still need to test some feature that is available only in dev -- consider switch to some stable branch and cherry-pick changes you are interested in.
I was getting this error when trying to build Qt itself from sources with Visual Studio 16 2019 generator. Turned out, it is not supported (yet?), so I had to use Ninja generator instead (and set C/C++ compiler to cl.exe) - then the configuration and build went fine.
So perhaps that is the case with building projects too - you should check if you are using Ninja (and switch to it if not).

unknown type name '_declspec' on cmake

I am trying to generate a shared native library using cmake. the contents of this library are nothing more than native functions that will later be used in Unity. that is why the functions have the extension __declspec (dllexport) so that in the Unity section they can be called with dllImport.
My problem comes when I try to compile that library in cmake. I am using Ninja as compiled and cross-compiled with Android toolchain. The problem is that it tells me:
../InnovaeInterface/include/Camara.h:7:2: error: unknown type name '_declspec'
_declspec(dllexport) CameraUtils::Calibration* createCamara(void);
^
../InnovaeInterface/include/Camara.h:7:22: error: expected ';' after top level declarator
_declspec(dllexport) CameraUtils::Calibration* createCamara(void);
^
The truth is that I have no idea where to throw. I hope you help me.

How can I get a basic Fortran file to compile on Windows/MinGW using CMake?

I feel completely lost trying to get CMake to work on Windows. I have a project (ECCODES) that has Fortran and C files. I can compile Fortran files if I don't use CMake. But this project came with a ton of CMake files. I look at the error below and it says to me, "I (CMake) cannot compile a simple Fortran program even though you can compile Fortran files when you aren't using CMake." Can anyone make sense of this? I'm trying to use mingw64 since I can't use cygwin on this project for the Windows build. On Mac OS X and GNU/Linux everything builds fine, but I have to run this project on Windows...
Error:The Fortran compiler "c:/gcc-5.1.0-tdm64-1-fortran/bin/gfortran.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp
Run Build Command:"C:/mingw64/bin/mingw32-make.exe" "cmTC_93cb8/fast"
C:/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_93cb8.dir\build.make CMakeFiles/cmTC_93cb8.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp'
Building Fortran object CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj
c:\gcc-5.1.0-tdm64-1-fortran\bin\gfortran.exe -c C:\Users\knauthg\.CLion2016.1\system\cmake\generated\ECCodes-45f4e5f3\45f4e5f3\__default__\CMakeFiles\CMakeTmp\testFortranCompiler.f -o CMakeFiles\cmTC_93cb8.dir\testFortranCompiler.f.obj
CMakeFiles\cmTC_93cb8.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_93cb8.dir/testFortranCompiler.f.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/knauthg/.CLion2016.1/system/cmake/generated/ECCodes-45f4e5f3/45f4e5f3/__default__/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_93cb8/fast' failed
mingw32-make.exe: *** [cmTC_93cb8/fast] Error 2
CMake will not be able to correctly generate this project.
Before, I was using the tdm-gcc Windows 64-bit build of gfortran. I switched to the 64-bit build of gfortran by Simply Fortran, and now the entire ECCODES project builds to completion using CMake. I'm still using MingW64 gcc to compile the C files.
Hat tip to John Wasilewski on a thread of Physics Forums who gave the tip about Simply Fortran.