Tag Archives: cpp

The imported project “c:\Microsoft.Cpp.Default.props” was not found

npm is installed in this situation.

Theme:

Detection Method:

1, download Visual C++ 2015 Build Tools

Downloaded 38142142;: http://go.microsoft.com/fwlink/?LinkId=691126&_hstc=268264337.464d867a453cb3e0785b9f7f82b81bb9.1517626516073.1519263951770.1519269195452.4&_hssc=268264337.1.1519269195452&_hsfp=3527706607&fixForIE=.exe

2.download GTK, because you need to load some of it, download complete to C:\GTK immediately; download 3814214;(64 seconds): http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip

3. This is a very dependent step, inspiring cmd command, input set VCTargetsPath=C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \v4.0\v140;

Using vtk8.1 in qcreator

VS development VTK and ITK package setup is relatively complex, so we chose a lightweight IDE as the development tool.

Here Qt and VTK installation can refer to my previous article Win10 installation VS2017 + QT5.11 + VTK8.1.1 + ITK4.13, here focuses on how to use QCreator to use VTK.
This project’s GitHub address: Alxemade/VTK_ITK_SimpleTest/test_vtk/ Welcome Star and Fork.
1. Create a new Qt Console Application in QTCreator
The project structure is shown in the figure below:

Then we enter the following code in main.cpp:

#include <QCoreApplication>

#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkImageViewer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleImage.h>
#include <vtkJPEGReader.h>
#include <vtkRenderer.h>

#include<QVTKWidget.h>

int main(int argc,char **argv)
{
    QCoreApplication a(argc, argv);
    QVTKWidget widget;
    widget.resize(256,256);
    //Setupsphere
    vtkSmartPointer<vtkSphereSource>sphereSource=vtkSmartPointer<vtkSphereSource>::New();
    sphereSource->Update();
    vtkSmartPointer<vtkPolyDataMapper>sphereMapper=vtkSmartPointer<vtkPolyDataMapper>::New();
    sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
    vtkSmartPointer<vtkActor>sphereActor= vtkSmartPointer<vtkActor>::New();
    sphereActor->SetMapper(sphereMapper);
    //Setupwindow
    vtkSmartPointer<vtkRenderWindow>renderWindow=vtkSmartPointer<vtkRenderWindow>::New();
    //Setuprenderer
    vtkSmartPointer<vtkRenderer>renderer=vtkSmartPointer<vtkRenderer>::New();
    renderWindow->AddRenderer(renderer);
    renderer->AddActor(sphereActor);
    renderer->ResetCamera();
    widget.SetRenderWindow(renderWindow);
    //mainWindow.setCentralWidget(widget);

    //mainWindow.show();
    widget.show();
    app.exec();
    return EXIT_SUCCESS;

}

Note: this is only an initial version and will need to be revised in the end.
CMAKE, compile, run and find a bunch of errors. Never mind, we need to add the VTK header and lib files.
Add the following code:

INCLUDEPATH += $$quote(C:/Program Files/VTK/include/vtk-8.1)
LIBS +=  $$quote(C:/Program Files/VTK/lib/vtk*.lib)

In this case, the path is the path where the output has been compiled by VTK.
2. Run the program above
Error: cannot open QApplication
QT += widgets
2. 2 Qwidget Must constuct a Qappliaction before Qwidget
We separate the Debug and Release versions. Modify the PRO file as follows:

QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle
QT += widgets
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
        main.cpp

SysStatus = $$system(if exist %windir%/SysWOW64 echo x64)  ## if contains SysWOW64 prove the windows is 64 bit

win32 {
    ## Windows common build here
    !contains(SysStatus, x64) {
        message("x86 build ")
        ## Windows x86 (32bit) specific build here

    } else {
        message("x86_64 build")
        ## Windows x64 (64bit) specific build here
        LABMR_PREFIX = E:/XC/vtk/vtk-8.1.1/build/lib
        ## TOOLS_PREFIX = quote(C:/Program Files)
    }
}
##VTK INCLUDEPATH Starts
INCLUDEPATH += $$quote(C:/Program Files/VTK/include/vtk-8.1)
##VTK Ends

CONFIG(debug, debug|release) {

## VTK Debug LIB Starts
LIBS += $${LABMR_PREFIX}/Debug/vtk*.lib
## VTK Debug LIB Ends

} else {

## VTK Release LIB Starts
LIBS += $${LABMR_PREFIX}/Release/vtk*.lib
## VTK Release LIB Ends
}

Also modify the system environment variable to:

2. 3 still can not open the normal file.
We have modified the CPP file:

    # include & lt; QCoreApplication> and oreApplication a(argc, argv); with Core removed. Add two lines:
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);

The final CPP file is as follows:

#include <QApplication>
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);

#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkImageViewer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleImage.h>
#include <vtkJPEGReader.h>
#include <vtkRenderer.h>

#include<QVTKWidget.h>

int main(int argc,char **argv)
{
    //QCoreApplication a(argc, argv);
    QApplication app(argc, argv);
    QVTKWidget widget;
    widget.resize(256,256);
    //Setupsphere
    vtkSmartPointer<vtkSphereSource>sphereSource=vtkSmartPointer<vtkSphereSource>::New();
    sphereSource->Update();
    vtkSmartPointer<vtkPolyDataMapper>sphereMapper=vtkSmartPointer<vtkPolyDataMapper>::New();
    sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
    vtkSmartPointer<vtkActor>sphereActor= vtkSmartPointer<vtkActor>::New();
    sphereActor->SetMapper(sphereMapper);
    //Setupwindow
    vtkSmartPointer<vtkRenderWindow>renderWindow=vtkSmartPointer<vtkRenderWindow>::New();
    //Setuprenderer
    vtkSmartPointer<vtkRenderer>renderer=vtkSmartPointer<vtkRenderer>::New();
    renderWindow->AddRenderer(renderer);
    renderer->AddActor(sphereActor);
    renderer->ResetCamera();
    widget.SetRenderWindow(renderWindow);
    //mainWindow.setCentralWidget(widget);

    //mainWindow.show();
    widget.show();
    app.exec();
    return EXIT_SUCCESS;

}

Then cmake, compile, and run:

Over

The word that writes this basically is the word that oneself need to check later is more convenient.

[tools] vscode debug report G + +. Exe no such file or directory fatal error no input files

Yesterday, we set up the debugging environment of VSCode Cpp breakpoint. It could still run at noon, but it started to report errors in the evening. According to the environment set up by the article I published, when I tried to debug by pressing F5, the error was reported as follows:


watch VSCode integrated in the TERMINAL error
g + +. The exe: error: e: ProjectsVSCodeCppTest5srctest. CPP: No to the file or directory
here's e: ProjectsVSCodeCppTest5srctest. CPP should actually be e: \ Projects \ VSCode \ CPP \ Test5 \ SRC \ test CPP.
but is resolved to an address without a slash, so the compiler cannot find the file.
Turns out, the reason for this error parse is because. Different terminals parse slashes and backslashes differently. Yesterday, after configuring the environment, I happened to find that VS Code integrated terminal itself, and also integrated all terminals in the environment, including PowerShellCommand Prompt (CMD) , and Git Bash. When using the shortcut key CTRL + shift + ~ to open the terminal, click the drop-down arrow on the right to select the default open terminal.

click Select Default Shell, all shells in the environment will pop up at the top of the interface for selection.

select Git Bash and F5 debug Cpp code, it will report the opening error. When you select PowerShell or Command Prompt, you are ready to debug normally!
Note that the default shell cannot be selected by clicking the drop-down menu when
error is reported. You need to open a terminal by yourself with the shortcut key.

How to Use paho.mqtt.cpp

install deploy

preparation

$ sudo apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
$ sudo apt-get install libssl-dev 
$ sudo apt-get install doxygen graphviz

paho.mqtt.c installation

$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c
$ git checkout v1.3.1

$ cmake -Bbuild -H. -DPAHO_WITH_SSL=ON -DPAHO_ENABLE_TESTING=OFF
$ sudo cmake --build build/ --target install
$ sudo ldconfig

paho.mqtt.cpp installation

$ git clone https://github.com/eclipse/paho.mqtt.cpp
$ cd paho.mqtt.cpp
$ cmake -Bbuild -H. -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE
$ sudo cmake --build build/ --target install
$ sudo ldconfig

basically USES