I created a DLL project by following this Microsoft tutorial, which works fine.
Now, I tried to modify the .h and .cpp files and include a vtkPolydata
as follows.
SurfaceGeneration.h
#pragma once
#ifdef SURFACEGENERATION_EXPORTS
#define SURFACEGENERATION_API __declspec(dllexport)
#else
#define SURFACEGENERATION_API __declspec(dllimport)
#endif
// Load the playdoh model and the polylines text file
extern "C" SURFACEGENERATION_API void sg_init(
const std::string data_folder, const std::string _playdoh_filename, const std::string _polyline_filename);
// Apply the surface generation algorithm to the playdoh model based on the polylines in the text file.
extern "C" SURFACEGENERATION_API bool sg_execute();
SurfaceGeneration.cpp
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <utility>
#include <limits.h>
#include <iostream>
#include <string>
#include "SurfaceGeneration.h"
#include <vtk-9.0/vtkPolyData.h>
// DLL internal state variables: none
void sg_init(const std::string data_folder, const std::string _playdoh_filename, const std::string _polyline_filename)
{
}
// Returns true on success, false on failure.
bool sg_execute()
{
return true;
}
Then, it throws the following 15 errors in vtkBuffer
:
> Error C2589 '(': illegal token on right side of
> '::' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C2065 'newArray': undeclared
> identifier SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C2065 'newArray': undeclared
> identifier SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 224
> Error C2760 syntax error: ')' was unexpected here; expected
> ';' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C2760 syntax error: ')' was unexpected here; expected
> ';' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C2760 syntax error: ')' was unexpected here; expected
> '}' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C2760 syntax error: ':' was unexpected here; expected
> ';' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token '(' following
> 'expression' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'compound_statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'expression_statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'expression_statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'selection_statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ')' following
> 'statement_seq' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
> Error C3878 syntax error: unexpected token ':' following
> 'expression_statement' SurfaceGenerationDLL C:\vcpkg\installed\x64-windows\include\vtk-9.0\vtkBuffer.h 222
How can I fix this?
Note that I used vcpkg to install the VTK package, and I didn't encounter any problem/error with VTK in my console application project.