# CMake works for Linux but not for Windows: runtime error, DLLS not found

**URL:** https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998
**Category:** Usage
**Created:** [November 20, 2024, 10:05am UTC](https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998 "2024-11-20T10:05:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ferdymercury](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ferdymercury/32/5134_2.png) [@ferdymercury](https://discourse.cmake.org/u/ferdymercury)
#### Post date: [November 20, 2024, 10:05am UTC](https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998/1 "2024-11-20T10:05:29Z")

</div>

I have a CMake project which builds fine both on Windows and on Linux. However, the program only runs well on Linux. On Windows, it fails with a runtime error about the DLLs not being found in the runtime path:

```auto
[Qt] Error(s):
[Qt] Cannot load library C:\e\e\_Extensions\SlicerRT_R\inner-build\lib\Slicer-5.7\qt-loadable-modules\Release\qSlicerRoomsEyeViewModule.dll: The specified module could not be found.
DLL load failed while importing vtkSlicerBeamsModuleLogicPython: The specified module could not be found.

```

More details here:

> <https://github.com/SlicerRt/SlicerRT/pull/254#issuecomment-2416617388>
>
> Build works on Windows as well. The problem with finding the DLL is still there …though. This is the error at startup. It seems the Beams module cannot locate the IEC dll.
> 
> \`\`\`
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerBeamsModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerDicomRtImportExportModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerDicomSroImportExportModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerDrrImageComputationModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerExternalBeamPlanningModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerPlmProtonDoseEngineModule.dll: The specified module could not be found.
> \[Qt\] Error(s):
> \[Qt\] Cannot load library C:\\e\\e\\\_Extensions\\SlicerRT\_R\\inner-build\\lib\\Slicer-5.7\\qt-loadable-modules\\Release\\qSlicerRoomsEyeViewModule.dll: The specified module could not be found.
> DLL load failed while importing vtkSlicerBeamsModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerBeamsModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerBeamsModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomRtImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomRtImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomRtImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomSroImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomSroImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDicomSroImportExportModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDrrImageComputationModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDrrImageComputationModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerDrrImageComputationModuleLogicPython: The specified module could not be found.
> Failed to load vtkSlicerExternalBeamPlanningModuleLogicPython: No module named vtkSlicerBeamsModuleLogicPython
> Failed to load vtkSlicerExternalBeamPlanningModuleLogicPython: No module named vtkSlicerBeamsModuleLogicPython
> Failed to load vtkSlicerExternalBeamPlanningModuleLogicPython: No module named vtkSlicerBeamsModuleLogicPython
> DLL load failed while importing vtkSlicerRoomsEyeViewModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerRoomsEyeViewModuleLogicPython: The specified module could not be found.
> DLL load failed while importing vtkSlicerRoomsEyeViewModuleLogicPython: The specified module could not be found.
> DLL load failed while importing qSlicerBeamsModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerBeamsModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerBeamsModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerExternalBeamPlanningModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerExternalBeamPlanningModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerExternalBeamPlanningModuleWidgetsPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerPlmProtonDoseEngineDoseEnginesPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerPlmProtonDoseEngineDoseEnginesPythonQt: The specified module could not be found.
> DLL load failed while importing qSlicerPlmProtonDoseEngineDoseEnginesPythonQt: The specified module could not be found.
> \[Qt\] When loading module "BatchStructureSetConversion" , the dependency "DicomRtImportExport" failed to be loaded.
> \[Qt\] When loading module "IGRTWorkflow\_SelfTest" , the dependency "DicomRtImportExport" failed to be loaded.
> \`\`\`

I am out of ideas on what to try, since I am more an expert on the Linux side but have no experience in the Windows part.

Any orientation on what to try would be greatly appreciated. (If someone wants to reproduce the runtime error, one needs first to build Slicer3D and then the SlicerRt extension. Both are available open-source on GitHub.)

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [November 20, 2024, 11:07am UTC](https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998/2 "2024-11-20T11:07:56Z")

</div>

Windows does not have the concept of storage of paths inside the executable where to locate shared libraries. So you have to update `PATH` environment variable to expect the executable to find the shared libraries.

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [November 20, 2024, 11:56am UTC](https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998/3 "2024-11-20T11:56:11Z")

</div>

…or copy the library to the same directory.

---

<div class="post-metadata">

### Author: ![ferdymercury](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ferdymercury/32/5134_2.png) [@ferdymercury](https://discourse.cmake.org/u/ferdymercury)
#### Post date: [November 24, 2024, 10:10am UTC](https://discourse.cmake.org/t/cmake-works-for-linux-but-not-for-windows-runtime-error-dlls-not-found/12998/4 "2024-11-24T10:10:38Z")

</div>

Thanks for your hints. Now I managed to make it work, it runs without warnings from the build direcotry. The only thing that still fails is “make package”, which creates a zip via CPack. There, the dll is still missing and thus if running from there, it will give the same error.
