Qt line causes strange error: Cmd.exe exited with code -20

  adtf, c++, qchart, qt

I am building my project on 2 different PCs, both using the same methods (Visual Studio 2017 with CMake). They both configure and generate fine using CMake. The issue is when I try to build them, one builds fine and the other has errors.

I have isolated the cause of this error and it seems to be whenever I try to instantiate either QLineSeries or QChart. There are NO red squiggles underneath my code. It all looks fine, until I try to instantiate either and then those errors appear.

I use QLineSeries a lot (I have 3 series), and I slowly commented out code until I found the culprit. The first line, me trying to create lineRedSeries = new QLineSeries; results in the errors below. Also, even if I comment out everything and try to create QChart *chart = new QChart();, it also causes the same errors.

Curiously enough, just declaring QLineSeries and QChartView in my h file doesn’t cause this issue (so if I comment out the code in my cpp file). It’s only when I try to create a QLineSeries or QChart that the errors occur.

I have removed a lot of unnecessary functions that are not pertinent for this question as my cpp file is quite long.

In my main.h:

#include <QtCharts> // for QLineSeries, QChartView, Chart
#include <QChartView>

class ExampleProject
{
public:
    ExampleProject();
    ~ExampleProject();

private:
    int OpenGraphic();

private:
    QLineSeries *lineRedSeries, *lineGreenSeries, *lineBlueSeries;
    QChartView *chartView;
};

In my main.cpp:

#include "main.h"
#include <QApplication>
#include <QMainWindow>
#include <iostream>

int ExampleProject::OpenGraphic()
{
    char *myargv[1];
    int myargc = 1;
    myargv[0] = strdup("");

    // First, create QApplication
    QApplication a(myargc, myargv);

    // Create our lineChart Series
    lineRedSeries = new QLineSeries; // The most FIRST line and causes errors!
    lineRedSeries->setName("RedSeries");
    lineRedSeries->setColor(Qt::red);
    lineRedSeries->append(1, 20);
    lineRedSeries->append(2, 30);
    lineRedSeries->append(3, 44);

    lineGreenSeries = new QLineSeries;
    lineGreenSeries->setName("GreenSeries");
    lineGreenSeries->setColor(Qt::green);
    lineGreenSeries->append(1, 10);
    lineGreenSeries->append(2, -9);
    lineGreenSeries->append(3, 20);
    lineGreenSeries->append(10, -40);

    lineBlueSeries = new QLineSeries;
    lineBlueSeries->setName("BlueSeries");
    lineBlueSeries->setColor(Qt::blue);
    lineBlueSeries->append(1, -20);
    lineBlueSeries->append(2, -10);
    lineBlueSeries->append(3, 0);

    QChart *chart = new QChart();
    chart->setTitle("Acceleration Graph");
    chart->setAcceptHoverEvents(true);

    // Add series to chart
    chart->addSeries(lineRedSeries);
    chart->addSeries(lineGreenSeries);
    chart->addSeries(lineBlueSeries);
    
    // Customize axes for chart
    chart->createDefaultAxes();
    chart->axes(Qt::Horizontal).back()->setRange(0, 131);
    chart->axes(Qt::Vertical).back()->setRange(-50, 50);
    chart->axes(Qt::Horizontal).back()->setTitleText("Time [s]");
    chart->axes(Qt::Vertical).back()->setTitleText("Acceleration [m/s]");

    // Create chartView
    chartView = new QChartView(chart);
    chartView->setRenderHint(QPainter::Antialiasing);
    
    // Render everything within our Window
    QMainWindow mainWindow;
    mainWindow.setCentralWidget(chartView);
    mainWindow.resize(400, 300);
    mainWindow.show();

    return a.exec();
}

The code will result in these errors:

the argument to a feature-test macro must be a simple identifier, qcompilerdetection.h, Line 1349
the argument to a feature-test macro must be a simple identifier, qcompilerdetection.h, Line 1351
"cmd.exe" exited with code -20, Microsoft.CppCommon.targets, Line 209

Complete build output:

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Rebuild All started: Project: main, Configuration: Debug x64 ------
2>Automatic MOC and UIC for target main
2>Building Custom Rule C:/Path/To/Drive/src/main/CMakeLists.txt
2>mocs_compilation.cpp
2>main.cpp
2>C:PathToDrivesrcmainmain.cpp(132): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. See online help for details.
2>C:Program Files (x86)Windows KitsInclude.0.17763.0ucrtstring.h(536): note: see declaration of 'strdup'
2>   Creating library C:/Path/To/Drive/build/src/main/Debug/main.lib and object C:/Path/To/Drive/build/src/main/Debug/main.exp
2>easy_profilerd.lib(block.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(block.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>easy_profilerd.lib(easy_socket.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(easy_socket.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>easy_profilerd.lib(event_trace_win.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(event_trace_win.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>easy_profilerd.lib(nonscoped_block.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(nonscoped_block.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>easy_profilerd.lib(profile_manager.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(profile_manager.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>easy_profilerd.lib(thread_storage.obj) : warning LNK4099: PDB 'easy_profiler.pdb' was not found with 'easy_profilerd.lib(thread_storage.obj)' or at 'C:PathToDrivebuildsrcmainDebugeasy_profiler.pdb'; linking object as if no debug info
2>main.vcxproj -> C:PathToDrivebuildsrcmainDebugmain.adtfplugin
2>-- Installing: C:/Path/To/Drive/base/tools/adtf/addons/Training/bin/debug/main.adtfplugin
2>-- Installing: C:/Path/To/Drive/base/tools/adtf/addons/Training/bin/debug/main.pdb
2>Done building project "main.vcxproj".
3>------ Rebuild All started: Project: main_pdgen, Configuration: Debug x64 ------
3>Generating Debug/main.plugindescription
3>2021-09-02 12:44:12 [INFO]: Try to load "C:PathToDrivebasetoolsadtfbindebugadtf_core.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:12 [INFO]: Loaded plugin: "C:PathToDrivebasetoolsadtfbindebugadtf_core.adtfplugin" (Build Type: Debug) [runtime.cpp(1895)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "session_manager.service.adtf.cid". ( 1 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "rpc_object_registry.service.adtf.cid". ( 2 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "core_sample_stream_tracer.service.adtf.cid". ( 3 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [DUMP]: Registered plugin "C:PathToDrivebasetoolsadtfbindebugadtf_core.adtfplugin", plugins in registry: 2 [runtime.cpp(1422)]
3>2021-09-02 12:44:12 [INFO]: Try to load "C:PathToDrivebasetoolsadtfbindebugdefault_core_objects.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:12 [INFO]: Loaded plugin: "C:PathToDrivebasetoolsadtfbindebugdefault_core_objects.adtfplugin" (Build Type: Debug) [runtime.cpp(1895)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "default_sample_stream.streaming.adtf.cid". ( 4 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "default_thread_runner.streaming.adtf.cid". ( 5 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "default_timer_runner.streaming.adtf.cid". ( 6 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "default_binding_proxy.streaming.adtf.cid". ( 7 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "sample_stream_merger.streaming.adtf.cid". ( 8 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "substream_selector.streaming.adtf.cid". ( 9 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "substream_assembler.streaming.adtf.cid". ( 10 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "substream_merger.streaming.adtf.cid". ( 11 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "substream_dissector.streaming.adtf.cid". ( 12 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "thread_mapper.streaming.adtf.cid". ( 13 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "thread_invoker.streaming.adtf.cid". ( 14 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "thread_reducer.streaming.adtf.cid". ( 15 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [DUMP]: Registered plugin "C:PathToDrivebasetoolsadtfbindebugdefault_core_objects.adtfplugin", plugins in registry: 3 [runtime.cpp(1422)]
3>2021-09-02 12:44:12 [INFO]: Try to load "C:PathToDrivebasetoolsadtfbindebugadtf_media_description.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:12 [INFO]: Loaded plugin: "C:PathToDrivebasetoolsadtfbindebugadtf_media_description.adtfplugin" (Build Type: Debug) [runtime.cpp(1895)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "media_description.service.adtf.cid". ( 16 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [DUMP]: Registered plugin "C:PathToDrivebasetoolsadtfbindebugadtf_media_description.adtfplugin", plugins in registry: 4 [runtime.cpp(1422)]
3>2021-09-02 12:44:12 [INFO]: Try to load "C:PathToDrivebasetoolsadtfbindebugadtf_kernel.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:12 [INFO]: Loaded plugin: "C:PathToDrivebasetoolsadtfbindebugadtf_kernel.adtfplugin" (Build Type: Debug) [runtime.cpp(1895)]
3>2021-09-02 12:44:17 [ERROR]: Could not register plugin in runtime Result code '-20 '(ERR_NOT_FOUND) - Could not load plugin "C:PathToDrivebasetoolsadtfaddonsaddons-toolboxbindebugmain.adtfplugin": file or dependencies not found [File: c:jworkspacedtf-builder_release_3.11.1_luckyreposrclibrariesucom3srcruntime.cpp] [Line: 1825] [Func: adtf::ucom::ant::detail::cRuntime::cRuntimePrivate::LoadPluginImpl]
3> [File: c:jworkspacedtf-builder_release_3.11.1_luckyreposrclibrariesucom3srcruntime.cpp] [Line: 1359] [Func: adtf::ucom::ant::detail::cRuntime::cRuntimePrivate::RegisterPlugin] [main.cpp(161)]
3>2021-09-02 12:44:17 [ERROR]: Result code '-20 '(ERR_NOT_FOUND) - Could not load plugin "C:PathToDrivebasetoolsadtfaddonsaddons-toolboxbindebugmain.adtfplugin": file or dependencies not found [File: c:jworkspacedtf-builder_release_3.11.1_luckyreposrclibrariesucom3srcruntime.cpp] [Line: 1825] [Func: adtf::ucom::ant::detail::cRuntime::cRuntimePrivate::LoadPluginImpl]
3> [File: c:jworkspacedtf-builder_release_3.11.1_luckyreposrclibrariesucom3srcruntime.cpp] [Line: 1359] [Func: adtf::ucom::ant::detail::cRuntime::cRuntimePrivate::RegisterPlugin] [main.cpp(703)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "kernel.service.adtf.cid". ( 17 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [DUMP]: Registered plugin "C:PathToDrivebasetoolsadtfbindebugadtf_kernel.adtfplugin", plugins in registry: 5 [runtime.cpp(1422)]
3>2021-09-02 12:44:12 [INFO]: Try to load "C:PathToDrivebasetoolsadtfbindebugadtf_clock.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:12 [INFO]: Loaded plugin: "C:PathToDrivebasetoolsadtfbindebugadtf_clock.adtfplugin" (Build Type: Debug) [runtime.cpp(1895)]
3>2021-09-02 12:44:12 [INFO]:     Registered class "reference_clock.service.adtf.cid". ( 18 ) [runtime.cpp(2182)]
3>2021-09-02 12:44:12 [DUMP]: Registered plugin "C:PathToDrivebasetoolsadtfbindebugadtf_clock.adtfplugin", plugins in registry: 6 [runtime.cpp(1422)]
3>2021-09-02 12:44:12 [INFO]: Using settings from:C:/Path/To/Drive/AppDataLocalDigitalwerkADTF-Configuration-Editor_3.11.1adtf_configuration_editor.cesettings [main.cpp(601)]
3>2021-09-02 12:44:17 [DUMP]: Will increase runlevel to "RL_System" [runtime.cpp(715)]
3>2021-09-02 12:44:17 [INFO]: Started UCOM runtime [runtime.cpp(1063)]
3>2021-09-02 12:44:17 [INFO]: Switched main clock to 'adtf'. [clock_srv.cpp(353)]
3>2021-09-02 12:44:17 [INFO]: Switched stream clock to 'adtf_stream'. [clock_srv.cpp(392)]
3>2021-09-02 12:44:17 [INFO]: Initializing service "reference_clock.services.adtf" [runtime.cpp(765)]
3>2021-09-02 12:44:17 [INFO]: No RPC Object Registry available to register clock for RPC calls [clock_srv.cpp(173)]
3>2021-09-02 12:44:17 [INFO]: Initialized service "reference_clock.services.adtf" [runtime.cpp(796)]
3>2021-09-02 12:44:17 [INFO]: Initializing service "kernel.services.adtf" [runtime.cpp(765)]
3>2021-09-02 12:44:17 [INFO]: Initialized service "kernel.services.adtf" [runtime.cpp(796)]
3>2021-09-02 12:44:17 [INFO]: Initializing service "media_description.services.adtf" [runtime.cpp(765)]
3>2021-09-02 12:44:17 [INFO]: Initialized service "media_description.services.adtf" [runtime.cpp(796)]
3>2021-09-02 12:44:17 [INFO]: Try to load "C:PathToDrivebasetoolsadtfaddonsaddons-toolboxbindebugmain.adtfplugin" [runtime.cpp(1788)]
3>2021-09-02 12:44:17 [INFO]: Deinit all services, filter, streamingservices [main.cpp(325)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "reference_clock.service.adtf.cid". ( 17 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "kernel.service.adtf.cid". ( 16 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "media_description.service.adtf.cid". ( 15 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "thread_reducer.streaming.adtf.cid". ( 14 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "thread_invoker.streaming.adtf.cid". ( 13 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "thread_mapper.streaming.adtf.cid". ( 12 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "substream_dissector.streaming.adtf.cid". ( 11 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "substream_merger.streaming.adtf.cid". ( 10 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "substream_assembler.streaming.adtf.cid". ( 9 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "substream_selector.streaming.adtf.cid". ( 8 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "sample_stream_merger.streaming.adtf.cid". ( 7 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "default_binding_proxy.streaming.adtf.cid". ( 6 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "default_timer_runner.streaming.adtf.cid". ( 5 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "default_thread_runner.streaming.adtf.cid". ( 4 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "default_sample_stream.streaming.adtf.cid". ( 3 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "core_sample_stream_tracer.service.adtf.cid". ( 2 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "rpc_object_registry.service.adtf.cid". ( 1 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]:     Unregistered class "session_manager.service.adtf.cid". ( 0 ) [runtime.cpp(2226)]
3>2021-09-02 12:44:17 [INFO]: Unloading plugin: "ADTF Clock Service Plugin" [runtime.cpp(1904)]
3>2021-09-02 12:44:17 [INFO]: Unloading plugin: "ADTF Kernel Service Plugin" [runtime.cpp(1904)]
3>2021-09-02 12:44:17 [INFO]: Unloading plugin: "ADTF Media Description Service Plugin" [runtime.cpp(1904)]
3>2021-09-02 12:44:17 [INFO]: Unloading plugin: "ADTF Default Core Objects Plugin" [runtime.cpp(1904)]
3>2021-09-02 12:44:17 [INFO]: Unloading plugin: "ADTF Session Manager Plugin" [runtime.cpp(1904)]
3>2021-09-02 12:44:17 [INFO]: Stopped UCOM runtime [runtime.cpp(1093)]
3>C:Program Files (x86)Microsoft Visual Studio17ProfessionalCommon7IDEVCVCTargetsMicrosoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code -20.
3>Done building project "main_pdgen.vcxproj" -- FAILED.
========== Rebuild All: 2 succeeded, 1 failed, 0 skipped ==========

In qcompilerdetection.h, it refers to lines 1349 and 1351 specifically:
enter image description here

I have included the proper Additional Include Directories within C/C++ > General and the correct .lib files in Linker > Input in VS. My includes are also correct. Any insight is appreciated.

Source: Windows Questions C++

LEAVE A COMMENT