# ParaView plugin project structure

**URL:** https://discourse.paraview.org/t/paraview-plugin-project-structure/6398
**Category:** Development
**Created:** [February 5, 2021, 10:18am UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398 "2021-02-05T10:18:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![PetiteViking](https://discourse.paraview.org/user_avatar/discourse.paraview.org/petiteviking/32/4074_2.png) [@PetiteViking](https://discourse.paraview.org/u/PetiteViking)
#### Post date: [February 5, 2021, 10:18am UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398/1 "2021-02-05T10:18:20Z")

</div>

Hi,  
I am currently trying to make the switch from Inviwo to Paraview but the Plugin/module structure seems to elude me.

The project structure I have so far looks like as shown below. I have more filters but for the sake of simplicity I’ll only go through one here. The code is available at [OpenTensorVis](https://github.com/JochenJankowai/OpenTensorVis/tree/master/paraview/OpenTensorVis).

```auto
├── CMakeLists.txt
├── OpenTensorVis
│ ├── CMakeLists.txt
| |── opentensorvis.plugin
│ ├── TensorFieldCriticalCellsFilter
│ │ ├── CMakeLists.txt
│ │ ├── tensorfieldcriticalcells.module
│ │ ├── TensirFieldCriticalCellsFilter.xml
│ │ ├── vtkTensorFieldCriticalCells.cxx
│ │ └── vtkTensorFieldCriticalCells.h

```

The top level `CMakeLists.txt` contains

```auto
cmake_minimum_required(VERSION 3.8)
project(OpenTensorVis-ParaView-Plugins)

find_package(ParaView REQUIRED)

set(CMAKE_CXX_STANDARD 20)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

set("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
paraview_plugin_scan(
  PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/OpenTensorVis/opentensorvis.plugin"
  PROVIDES_PLUGINS opentensorvis
  REQUIRES_MODULES required_modules)

foreach (module IN LISTS required_modules)
  if (NOT TARGET "${module}")
    message(#FATAL_ERROR
      "Skipping example ${CMAKE_PROJECT_NAME}: Missing required module: "
      "${module}")
    return ()
  endif ()
endforeach ()

paraview_plugin_build(
  RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
  LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}"
  PLUGINS ${opentensorvis})

```

The `opentensorvis.plugin` file:

```auto
NAME
  OpenTensorVis
DESCRIPTION
  Implementations of the algorithms and methods developed in the OpenTensorVis project.
REQUIRES_MODULES
  VTK::CommonCore
  VTK::FiltersCore

```

The `CMakeLists.txt` for the plugin simply contains

```auto
paraview_add_plugin(OpenTensorVis
  VERSION "1.0"
  MODULES
    OpenTensorVis::TensorFieldCriticalCellsFilter
  MODULE_FILES
    "${CMAKE_CURRENT_SOURCE_DIR}/TensorFieldCriticalCellsFilter/tensorfieldcriticalcells.module"
)

```

Last but not least, the `tensorfieldcriticalcells.module` file defines a simple module:

```auto
NAME
  OpenTensorVis::TensorFieldCriticalCellsFilter
LIBRARY_NAME
  vtkTensorFieldCriticalCellsFilter
DEPENDS
  VTK::FiltersCore
PRIVATE_DEPENDS
  VTK::CommonCore

```

with a corresponding `CMakeLists.txt`:

```auto
set(vtkTensorFieldCriticalCellsClasses
  vtkTensorFieldCriticalCells)

vtk_module_add_module(OpenTensorVis::TensorFieldCriticalCellsFilter
  CLASSES ${vtkTensorFieldCriticalCellsClasses})

paraview_add_server_manager_xmls(
  XMLS TensorFieldCriticalCellsFilter.xml
)

```

CMake runs fine and everything compiles but when trying to load the plugin, ParaView throws the error

```auto
ERROR: In C:\bbd\6c27b535\build\superbuild\paraview\src\Remoting\Core\vtkPVPluginLoader.cxx, line 519
vtkPVPluginLoader (000001D855F1F2F0): The specified module could not be found.

```

I suppose I am mixing things up somewhere and I’d be happy about pointers as to where to look. Thanks!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2021, 10:20am UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398/2 "2021-02-05T10:20:40Z")

</div>

You are not loading the right .so file, it is deeper in the build.

Modify your `CMakeLists.txt` like this to avoid this issue and generate a single .so file.

```auto
set(vtkTensorFieldCriticalCellsClasses
  vtkTensorFieldCriticalCells)

vtk_module_add_module(OpenTensorVis::TensorFieldCriticalCellsFilter
  FORCE_STATIC
  CLASSES ${vtkTensorFieldCriticalCellsClasses})

paraview_add_server_manager_xmls(
  XMLS TensorFieldCriticalCellsFilter.xml
)

```

---

<div class="post-metadata">

### Author: ![PetiteViking](https://discourse.paraview.org/user_avatar/discourse.paraview.org/petiteviking/32/4074_2.png) [@PetiteViking](https://discourse.paraview.org/u/PetiteViking)
#### Post date: [February 5, 2021, 11:49am UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398/3 "2021-02-05T11:49:19Z")

</div>

Hi,  
thanks for the quick reply. I tried it out but ParaView throws the same error.

I’m just groping in the dark here but could the namespace in `OpenTensorVis::TensorFieldCriticalCellsFilter` cause trouble? Or the fact that the plugin is called OpenTensorVis and the namespace as well?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 5, 2021, 11:50am UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398/4 "2021-02-05T11:50:09Z")

</div>

maybe, it is hard to say. I’d suggest trying with one the example that has a similar architecture and expand from there.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [February 5, 2021, 2:38pm UTC](https://discourse.paraview.org/t/paraview-plugin-project-structure/6398/5 "2021-02-05T14:38:25Z")

</div>

Does `ldd` have all libraries satisfied when you run it on the plugin that you’re trying to load? If not, you may be missing RPATH information somewhere. The output of `readelf -d` on the file may help there too.
