VTK 9.5.2: vtk_glad linker errors

Hello,

I’m upgrading my solution from VTK 8.2.2 to 9.5.2 and have built VTK 9.5.0 as static libraries. After updating my code, I’m encountering linker errors:

error LNK2001: unresolved external symbol vtk_glad_*

If I understand correclty, vtkglew-8.2.lib has been replaced by vtkglad-9.5.lib in VTK 9.x.

My VTK 8.2.0 project did not explicitly reference vtkglew-8.2.lib but I added vtkglad-9.5.lib to my additional dependencies, and the linker errors persist.

My current linker config is:

<Link>
  <AdditionalDependencies>gdi32.lib;glu32.lib;opengl32.lib;User32.lib;vtkglad-9.5.lib;vtkInteractionStyle-9.5.lib;vtkCommonCore-9.5.lib;vtkCommonDataModel-9.5.lib;vtkCommonExecutionModel-9.5.lib;vtkCommonMath-9.5.lib;vtkCommonSystem-9.5.lib;vtkCommonMisc-9.5.lib;vtkCommonTransforms-9.5.lib;vtkFiltersCore-9.5.lib;vtkFiltersGeneral-9.5.lib;vtkFiltersGeneric-9.5.lib;vtkFiltersGeometry-9.5.lib;vtkFiltersImaging-9.5.lib;vtkFiltersModeling-9.5.lib;vtkFiltersParallel-9.5.lib;vtkFiltersSources-9.5.lib;vtkFiltersExtraction-9.5.lib;vtkFiltersTexture-9.5.lib;vtkImagingCore-9.5.lib;vtkInteractionImage-9.5.lib;vtkInteractionStyle-9.5.lib;vtkInteractionWidgets-9.5.lib;vtkIOCore-9.5.lib;vtkIOImage-9.5.lib;vtkIOXML-9.5.lib;vtkRenderingAnnotation-9.5.lib;vtkRenderingCore-9.5.lib;vtkRenderingFreeType-9.5.lib;vtkRenderingImage-9.5.lib;vtkRenderingLabel-9.5.lib;vtkRenderingOpenGL2-9.5.lib;vtkRenderingLOD-9.5.lib;vtkRenderingVolume-9.5.lib;vtksys-9.5.lib;log4cxx.lib</AdditionalDependencies>
</Link>

Am I missing any additional libraries or dependencies for VTK 9.5.0 static builds? Is there a specific linking order required for vtkglad-9.5.lib? Are there any other migration steps specific to the GLEW→GLAD transition?

I can provide the full build output if needed. Thank you for your help!

IIUC, you do not use find_package(VTK) from CMake to link your project against VTK?

My current linker config is: …

That should’ve worked. I’ve not tried static builds. For dynamic libs, glad needs GLAD_API_CALL_EXPORT when building and linking to it, and GLAD_API_CALL_EXPORT_BUILD when building it.

Maybe something is preventing the vtk_glad_* symbols from being visible? I will try static locally.

That’s correct — my project doesn’t use CMake. It’s a C++ project integrated into a larger C# solution, so I’m using Visual Studio and MSBuild for the build process. I’m manually specifying the VTK library dependencies in the .vcxproj file rather than using CMake’s find_package(VTK).

Thank you

I built vtk static libs and got a test CMake project to link with it successfully. Let me run that through the Visual Studio generator and see what it creates.

Okay. Here is the <Link> section CMake generated for the VTK tests.

Note the order. opengl32.lib appears after vtkglad-9.5.lib. I do not know if this matters.

    <Link>
      <AdditionalDependencies>..\..\..\..\lib\MinSizeRel\vtkRenderingCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonSystem-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersExtraction-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersGeneral-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersGeometry-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersProgrammable-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersSources-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersTexture-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkImagingSources-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkInteractionStyle-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOImage-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOLegacy-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOParallel-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOXML-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingAnnotation-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingOpenGL2-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingVRModels-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkTestingCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkTestingRendering-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOGeometry-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkjsoncpp-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersParallel-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersExtraction-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersStatistics-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkParallelDIY-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersTexture-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersModeling-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingOpenGL2-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingFreeType-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkfreetype-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingHyperTreeGrid-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersHybrid-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkImagingSources-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingUI-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkglad-9.5.lib;opengl32.lib;..\..\..\..\lib\MinSizeRel\vtkx11-9.5.lib;d3d11.lib;dxgi.lib;..\..\..\..\lib\MinSizeRel\vtkRenderingCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersSources-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonColor-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOImage-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkDICOMParser-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkmetaio-9.5.lib;comctl32.lib;wsock32.lib;..\..\..\..\lib\MinSizeRel\vtkpng-9.5.lib;..\..\..\..\lib\MinSizeRel\vtktiff-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkjpeg-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOXML-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOXMLParser-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkexpat-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkTestingCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersHyperTree-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersGeneral-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonComputationalGeometry-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersVerdict-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersGeometry-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkverdict-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkParallelCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOLegacy-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOCellGrid-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkIOCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkzlib-9.5.lib;..\..\..\..\lib\MinSizeRel\vtklz4-9.5.lib;..\..\..\..\lib\MinSizeRel\vtklzma-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersCellGrid-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkFiltersReduction-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkImagingColor-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkImagingCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonExecutionModel-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonDataModel-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonSystem-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkpugixml-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonMisc-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonTransforms-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonMath-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkCommonCore-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkfmt-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkscn-9.5.lib;..\..\..\..\lib\MinSizeRel\vtktoken-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkloguru-9.5.lib;..\..\..\..\lib\MinSizeRel\vtkkissfft-9.5.lib;..\..\..\..\lib\MinSizeRel\vtksys-9.5.lib;ws2_32.lib;dbghelp.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions>
      <DataExecutionPrevention></DataExecutionPrevention>
      <GenerateDebugInformation>false</GenerateDebugInformation>
      <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
      <ImageHasSafeExceptionHandlers></ImageHasSafeExceptionHandlers>
      <ImportLibrary>D:/dev/vtk-static/vtk/out/build/Debug/lib/MinSizeRel/vtkRenderingCoreCxxTests.lib</ImportLibrary>
      <LinkErrorReporting></LinkErrorReporting>
      <ProgramDataBaseFile>D:/dev/vtk-static/vtk/out/build/Debug/bin/MinSizeRel/vtkRenderingCoreCxxTests.pdb</ProgramDataBaseFile>
      <RandomizedBaseAddress></RandomizedBaseAddress>
      <SubSystem>Console</SubSystem>
    </Link>

You are right, the order matters. I have re-order the libraries:

		<AdditionalDependencies>
		<!-- High-level VTK interaction/widgets -->
		vtkInteractionStyle-9.5.lib;
		vtkInteractionWidgets-9.5.lib;
		vtkInteractionImage-9.5.lib;
		vtkRenderingAnnotation-9.5.lib;
		vtkRenderingVolume-9.5.lib;
		vtkRenderingLOD-9.5.lib;
		vtkRenderingLabel-9.5.lib;
		vtkRenderingImage-9.5.lib;
		vtkRenderingOpenGL2-9.5.lib;
		vtkRenderingFreeType-9.5.lib;
		vtkRenderingCore-9.5.lib;
		
		<!-- VTK OpenGL implementation -->
		vtkglad-9.5.lib;
		
		<!-- VTK Filters -->
		vtkFiltersTexture-9.5.lib;
		vtkFiltersParallel-9.5.lib;
		vtkFiltersModeling-9.5.lib;
		vtkFiltersImaging-9.5.lib;
		vtkFiltersGeometry-9.5.lib;
		vtkFiltersGeneric-9.5.lib;
		vtkFiltersGeneral-9.5.lib;
		vtkFiltersSources-9.5.lib;
		vtkFiltersExtraction-9.5.lib;
		vtkFiltersCore-9.5.lib;
		
		<!-- VTK IO -->
		vtkIOXML-9.5.lib;
		vtkIOImage-9.5.lib;
		vtkIOCore-9.5.lib;
		
		<!-- VTK Imaging -->
		vtkImagingCore-9.5.lib;
		
		<!-- VTK Common -->
		vtkCommonExecutionModel-9.5.lib;
		vtkCommonDataModel-9.5.lib;
		vtkCommonTransforms-9.5.lib;
		vtkCommonMisc-9.5.lib;
		vtkCommonMath-9.5.lib;
		vtkCommonSystem-9.5.lib;
		vtkCommonCore-9.5.lib;
		
		<!-- VTK system utilities -->
		vtksys-9.5.lib;
		
		<!-- External libraries -->
		log4cxx.lib;
		
		<!-- System libraries -->
		opengl32.lib;
		glu32.lib;
		gdi32.lib;
		User32.lib;
		%(AdditionalDependencies)
		</AdditionalDependencies>

Does this order seems good to you? I still get the linker errors with this modification.

Thank you

you still get linker errors. That is odd.

No, unfortunately the linker errors persist. I’m currently working on a minimal sample application to help diagnose the issue more effectively. I’ll post an update once I have it ready.

Thank you for your help!

I managed to reproduce the linker errors in a sample. I am not allowed to upload attachment, how can I send it to you?
I have compiled the latest release of VTK locally and packaged it in a nuget package. I can provide you the package if needed.

you can upload now.

Okay. Thanks for getting that ready. Try uploading once again. If that does not work, maybe create a small github project or gist?

Thank you

vtk_glad_sample.zip (1.6 MB)

Can you share the nuget package?

The nuget package is quite large (130MB), I had to upload it to my Google Drive account https://drive.google.com/file/d/1NhAxsrNyTzZlxM_x31SHtDAPpsVB5f4J/view?usp=sharing

Hello,

Did you have a chance to review the sample project and/or the NuGet package?

I’ve rebuilt the latest release from scratch following the documentation (Building - VTK documentation), repackaged it, and I’m still seeing the same behavior. I’m trying to determine whether the issue comes from the sample itself or from the VTK build I produced.

Any guidance or pointers would be appreciated. Thanks!

Hi Charles, Yes, i downloaded your nuget package, but I have not added it to the VS solution. Apologies for the delay, i’ve been working on other things. I will try to look into it today.

1 Like

Alright. I was able to import your nuget package into the visual studio project and reproduce the linker error that you saw.

I will now try to see what can be done to fix this. Thank you for providing the sample code and the nuget package.

@VCharles I think the nuget package you shared does not have static libraries at all. Did you forget BUILD_SHARED_LIBS=OFF?

The nuget package has .dll files. The .lib files you specify in the .vcxproj under AdditionalDependencies are not static libraries. They are actually import libs and not meant to be used that way.

Here is output of dumpbin.exe /SYMBOLS on the vtkglad-9.5.lib from your nuget package.

$ dumpbin.exe /SYMBOLS D:\dev\CharlesVTKGladIssue\VTK.Native.9.5.2-prerelease1\build\native\lib\x64\Debug\vtkglad-9.5d.lib
Microsoft (R) COFF/PE Dumper Version 14.44.35221.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file D:\dev\CharlesVTKGladIssue\VTK.Native.9.5.2-prerelease1\build\native\lib\x64\Debug\vtkglad-9.5d.lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 01018B85 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | __IMPORT_DESCRIPTOR_vtkglad-9.5d
002 C0000040 SECT2  notype       Section      | .idata$2
003 00000000 SECT3  notype       Static       | .idata$6
004 C0000040 UNDEF  notype       Section      | .idata$4
005 C0000040 UNDEF  notype       Section      | .idata$5
006 00000000 UNDEF  notype       External     | __NULL_IMPORT_DESCRIPTOR
007 00000000 UNDEF  notype       External     | vtkglad-9.5d_NULL_THUNK_DATA

String Table Size = 0x5C bytes

COFF SYMBOL TABLE
000 01018B85 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | __NULL_IMPORT_DESCRIPTOR

String Table Size = 0x1D bytes

COFF SYMBOL TABLE
000 01018B85 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | vtkglad-9.5d_NULL_THUNK_DATA

String Table Size = 0x22 bytes

  Summary

          D2 .debug$S
          14 .idata$2
          14 .idata$3
           8 .idata$4
           8 .idata$5
          12 .idata$6

Whereas, the output from my static build of VTK is totally different.

$ dumpbin.exe /SYMBOLS D:\dev\vtk-static\vtk\out\build\Debug\lib\Debug\vtkglad-9.5d.lib
Microsoft (R) COFF/PE Dumper Version 14.44.35221.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file D:\dev\vtk-static\vtk\out\build\Debug\lib\Debug\vtkglad-9.5d.lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 01048994 ABS    notype       Static       | @comp.id
001 80010190 ABS    notype       Static       | @feat.00
002 00000003 ABS    notype       Static       | @vol.md
003 00000000 SECT1  notype       Static       | .drectve
    Section length   5E, #relocs    0, #linenums    0, checksum        0
005 00000000 SECT2  notype       Static       | .debug$S
    Section length E0D8, #relocs  2F8, #linenums    0, checksum        0
007 00000000 SECT3  notype       Static       | .bss
    Section length  4A0, #relocs    0, #linenums    0, checksum        0
009 00000000 SECT3  notype       External     | VTK_GLAD_WGL_VERSION_1_0
00A 00000004 SECT3  notype       External     | VTK_GLAD_WGL_3DFX_multisample
00B 00000008 SECT3  notype       External     | VTK_GLAD_WGL_3DL_stereo_control
00C 0000000C SECT3  notype       External     | VTK_GLAD_WGL_AMD_gpu_association
00D 00000010 SECT3  notype       External     | VTK_GLAD_WGL_ARB_buffer_region
00E 00000014 SECT3  notype       External     | VTK_GLAD_WGL_ARB_context_flush_control
00F 00000018 SECT3  notype       External     | VTK_GLAD_WGL_ARB_create_context
....
40D 00002020 SECT3  notype       External     | vtk_glad_glGetTexParameterfv
40E 00002028 SECT3  notype       External     | vtk_glad_glGetTexParameteriv

Thank you for your answer! I am currently rebuilding VTK to test

It worked!

Thank you very much for your assistance :smile: