# Linking error: Undefined reference to \<vtkInteractor-derived class\>::New(). All VTK libraries linked, I suppose.

**URL:** https://discourse.vtk.org/t/linking-error-undefined-reference-to-vtkinteractor-derived-class-new-all-vtk-libraries-linked-i-suppose/949
**Category:** Support
**Created:** [May 10, 2019, 11:16am UTC](https://discourse.vtk.org/t/linking-error-undefined-reference-to-vtkinteractor-derived-class-new-all-vtk-libraries-linked-i-suppose/949 "2019-05-10T11:16:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 10, 2019, 11:16am UTC](https://discourse.vtk.org/t/linking-error-undefined-reference-to-vtkinteractor-derived-class-new-all-vtk-libraries-linked-i-suppose/949/1 "2019-05-10T11:16:30Z")

</div>

Greetings, all,

I’m trying to compile the code below:

```
#ifndef V3DMOUSEINTERACTORSTYLE_H
#define V3DMOUSEINTERACTORSTYLE_H
#include <vtkObjectFactory.h>
#include <vtkInteractorStyleTrackballCamera.h>

class v3dMouseInteractorStyle : public vtkInteractorStyleTrackballCamera
{
  public:
    static v3dMouseInteractorStyle* New();
    vtkTypeMacro(v3dMouseInteractorStyle, vtkInteractorStyleTrackballCamera);

    virtual void OnLeftButtonDown();

};

#endif

```

It throws an undefined reference to the New() function during linking time. I’ve read here ( [vtkScalarBarActor New macro problem](https://discourse.vtk.org/t/vtkscalarbaractor-new-macro-problem/610) ) that it is likely caused by some library missing library in liking command. Here is my `CMakeLists.txt`:

```
cmake_minimum_required(VERSION 3.7)

set(PROGNAME HorizontesPickProbe)

PROJECT(${PROGNAME})

set(CMAKE_PREFIX_PATH "C:/VTK64/install_release/lib/cmake" ${CMAKE_PREFIX_PATH})

find_package(VTK REQUIRED)

include(${VTK_USE_FILE})

set(CMAKE_AUTOMOC ON)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

file(GLOB_RECURSE UI_FILES *.ui)
file(GLOB_RECURSE QT_WRAP *.h)
file(GLOB_RECURSE CXX_FILES *.cpp)

qt5_wrap_ui(UISrcs ${UI_FILES} )

add_executable(${PROGNAME} ${CXX_FILES} ${UISrcs} ${QT_WRAP})

qt5_use_modules(${PROGNAME} Core Gui)

target_link_libraries(${PROGNAME} ${VTK_LIBRARIES})

```

Supposedly, the last line links the executable against all VTK libraries, since the CMake list does not explicitly list each library I intend to use.

Any help will be much appreciated,

Paulo

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 10, 2019, 12:09pm UTC](https://discourse.vtk.org/t/linking-error-undefined-reference-to-vtkinteractor-derived-class-new-all-vtk-libraries-linked-i-suppose/949/2 "2019-05-10T12:09:36Z")

</div>

Can you paste/upload the associated `.cpp` file?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 10, 2019, 12:14pm UTC](https://discourse.vtk.org/t/linking-error-undefined-reference-to-vtkinteractor-derived-class-new-all-vtk-libraries-linked-i-suppose/949/3 "2019-05-10T12:14:19Z")

</div>

Oh, thanks, the `.cpp` file was missing the macro that implements `New()`: `vtkStandardNewMacro(v3dMouseInteractorStyle);`
