Question about Emscripten example from the source code

I’ve tried to use cmake with the defined CMakeList.txt in the Examples/Emscripten/Cxx/Cone, but I wasn’t able to build and run successfully…

Do anyone has idea what’s wrong?

I didn’t use the docker, but instead I used emcmake cmake . and cmake --build ..
cmake seems working fine, but when I run cmake --build ., it gives tons of errors as below.

[1/2] Building CXX object CMakeFiles/Cone.dir/Cone.cxx.o
FAILED: CMakeFiles/Cone.dir/Cone.cxx.o
C:\workspace\emsdk\upstream\emscripten\em++.bat -DKISSFFT_DLL_IMPORT=1 -Dkiss_fft_scalar=double -DvtkRenderingCore_AUTOINIT_INCLUDE=\"C:/workspace/webassem/cone-ex/build/CMakeFiles/vtkModuleAutoInit_780e01f44c94c7648bee9e46e7d919c8.h\" -isystem "C:/Program Files (x86)/VTK/include/vtk-9.2" -isystem C:/workspace/emsdk/upstream/emscripten/system/include --bind -g3 -s EXPORT_NAME=vtkApp -s ALLOW_MEMORY_GROWTH=1 -s DEMANGLE_SUPPORT=1 -s EMULATE_FUNCTION_POINTER_CASTS=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s MODULARIZE=1 -s USE_PTHREADS=0 -s WASM=1 -O3 -std=gnu++11 -MD -MT CMakeFiles/Cone.dir/Cone.cxx.o -MF CMakeFiles\Cone.dir\Cone.cxx.o.d -o CMakeFiles/Cone.dir/Cone.cxx.o -c C:/workspace/webassem/cone-ex/Cone.cxx
em++: warning: linker setting ignored during compilation: 'EXPORT_NAME' [-Wunused-command-line-argument]      
em++: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
em++: warning: linker setting ignored during compilation: 'DEMANGLE_SUPPORT' [-Wunused-command-line-argument] 
em++: warning: linker setting ignored during compilation: 'EMULATE_FUNCTION_POINTER_CASTS' [-Wunused-command-line-argument]
em++: warning: linker setting ignored during compilation: 'ERROR_ON_UNDEFINED_SYMBOLS' [-Wunused-command-line-argument]
em++: warning: linker setting ignored during compilation: 'MODULARIZE' [-Wunused-command-line-argument]       
em++: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
em++: warning: linker flag ignored during compilation: '--bind' [-Wunused-command-line-argument]
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:28:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSystemIncludes.h:52:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStreamWrapper.h:44:7: error: variable has incomplete type 'class __declspec'
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStreamWrapper.h:44:7: note: forward declaration of '__declspec'
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:28:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSystemIncludes.h:52:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStreamWrapper.h:44:27: error: expected ';' after top level declarator
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
                          ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:28:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSystemIncludes.h:54:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStrStreamWrapper.h:36:7: error: redefinition of 'dllimport'    
class VTKCOMMONCORE_EXPORT vtkOStrStreamWrapper : public vtkOStreamWrapper
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStreamWrapper.h:44:7: note: previous definition is here        
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:28:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSystemIncludes.h:54:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStrStreamWrapper.h:36:27: error: expected ';' after top level declarator
class VTKCOMMONCORE_EXPORT vtkOStrStreamWrapper : public vtkOStreamWrapper
                          ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:31:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, const vtkIndent& o);
^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:33:7: error: redefinition of 'dllimport'
class VTKCOMMONCORE_EXPORT vtkIndent
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStreamWrapper.h:44:7: note: previous definition is here        
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:53:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:33:27: error: expected ';' after top level declarator  
class VTKCOMMONCORE_EXPORT vtkIndent
                          ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkIndent.h:34:1: error: expected unqualified-id
{
^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:70:7: error: redefinition of 'dllimport'
class VTKCOMMONCORE_EXPORT vtkObjectBase
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkOStrStreamWrapper.h:36:7: note: previous definition is here     
class VTKCOMMONCORE_EXPORT vtkOStrStreamWrapper : public vtkOStreamWrapper
      ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:47: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                              ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:45:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:70:27: error: expected ';' after top level declarator
class VTKCOMMONCORE_EXPORT vtkObjectBase
                          ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObjectBase.h:71:1: error: expected unqualified-id
{
^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:749:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayText(const char*);
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:750:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayErrorText(const char*);
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:751:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayWarningText(const char*);
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:752:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayGenericWarningText(const char*);
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:753:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayDebugText(const char*);
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:758:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayErrorText(
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:760:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayWarningText(
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
In file included from C:/workspace/webassem/cone-ex/Cone.cxx:11:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2\vtkActor.h:35:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp3D.h:37:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkProp.h:31:
In file included from C:/Program Files (x86)/VTK/include/vtk-9.2/vtkObject.h:46:
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkSetGet.h:762:8: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayGenericWarningText(
       ^
C:/Program Files (x86)/VTK/include/vtk-9.2/vtkCommonCoreModule.h:15:36: note: expanded from macro 'VTKCOMMONCORE_EXPORT'
#      define VTKCOMMONCORE_EXPORT __declspec(dllimport)
                                   ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
em++: error: 'C:/workspace/emsdk/upstream/bin\clang++.exe -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=C:\workspace\emsdk\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\fakesdl -Xclang -iwithsysroot/include\compat -DKISSFFT_DLL_IMPORT=1 -Dkiss_fft_scalar=double -DvtkRenderingCore_AUTOINIT_INCLUDE="C:/workspace/webassem/cone-ex/build/CMakeFiles/vtkModuleAutoInit_780e01f44c94c7648bee9e46e7d919c8.h" -isystem "C:/Program Files (x86)/VTK/include/vtk-9.2" -isystem C:/workspace/emsdk/upstream/emscripten/system/include -g3 -O3 -std=gnu++11 -MD -MT CMakeFiles/Cone.dir/Cone.cxx.o -MF CMakeFiles\Cone.dir\Cone.cxx.o.d -c C:/workspace/webassem/cone-ex/Cone.cxx -o CMakeFiles/Cone.dir/Cone.cxx.o' failed (returned 1)    
ninja: build stopped: subcommand failed.

Hi!

Looks like VTK export macro should not expand to declspec when cross-compiling to emscripten on windows. Please report this in https://gitlab.kitware.com/vtk/vtk/-/issues/new