If I use a library, do I need DLL file ?
-
I am trying to use VTK library into an MFC project ... I had do everything to can compile my project, (add headers and library files to my project), but when I try to run the program, I get follow error:
The program can't start because vtkRenderingCore-1.6.dll is missing from your computer
but I alreay use
vtkRenderingCore-1.6.lib
file (and his header), why do I need dll file ? I had used another library once upon a time(PDFlib), but then I had used just header file, and library file ... So, the question is, do I need a dll file if I am using library (and header file) inside the project ? -
I am trying to use VTK library into an MFC project ... I had do everything to can compile my project, (add headers and library files to my project), but when I try to run the program, I get follow error:
The program can't start because vtkRenderingCore-1.6.dll is missing from your computer
but I alreay use
vtkRenderingCore-1.6.lib
file (and his header), why do I need dll file ? I had used another library once upon a time(PDFlib), but then I had used just header file, and library file ... So, the question is, do I need a dll file if I am using library (and header file) inside the project ?Compiled libraries come in 2 flavors - static libraries and dynamic libraries. Static libraries are in the form of a .LIB file and dynamic libraries are in the form of a .DLL file. A .DLL file can also have an associated .LIB file. But this .LIB file only contains the exported function signatures and the name of the .DLL file. It does not contain any code. During runtime, the DLL file will be searched in specific folders as mentioned here - Dynamic-Link Library Search Order[^]
«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
-
Compiled libraries come in 2 flavors - static libraries and dynamic libraries. Static libraries are in the form of a .LIB file and dynamic libraries are in the form of a .DLL file. A .DLL file can also have an associated .LIB file. But this .LIB file only contains the exported function signatures and the name of the .DLL file. It does not contain any code. During runtime, the DLL file will be searched in specific folders as mentioned here - Dynamic-Link Library Search Order[^]
«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
I want to know the details of linker,do you have any suggestion?
-
I am trying to use VTK library into an MFC project ... I had do everything to can compile my project, (add headers and library files to my project), but when I try to run the program, I get follow error:
The program can't start because vtkRenderingCore-1.6.dll is missing from your computer
but I alreay use
vtkRenderingCore-1.6.lib
file (and his header), why do I need dll file ? I had used another library once upon a time(PDFlib), but then I had used just header file, and library file ... So, the question is, do I need a dll file if I am using library (and header file) inside the project ?Superman allready explained in his answer that in general there are two types of libaries (static and dynamic or also called shared libraries). Now when using VTK you can choose if you would like to use the static libraries or the dynamic ones. Assuming you did build VTK yourself in the CMake configuration you'll have to set the option BUILD_SHARED_LIBS=OFF. This way VTK will be build as static libraries.
-
Superman allready explained in his answer that in general there are two types of libaries (static and dynamic or also called shared libraries). Now when using VTK you can choose if you would like to use the static libraries or the dynamic ones. Assuming you did build VTK yourself in the CMake configuration you'll have to set the option BUILD_SHARED_LIBS=OFF. This way VTK will be build as static libraries.
-
Yes, that I already done it ... but still, I am not able to compile an MFC project with VTK, just console applications that had VTK inside ... :( I am still digging ....
-
Do you have problems compiling or linking? Because before you were talking about libraries and they only come into play afer you successfully compiled your pogram and now your telling that you have problems compiling.
Regor, kindly thank you. I am trying to compile their SampleMFC project, that has following CMakeList.txt:
cmake_minimum_required(VERSION 2.8)
PROJECT(Win32SampleMFC)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})This VTK_DIR usage only works in the VTK build tree...
Make it work in the "make install" tree, too.
INCLUDE("${VTK_DIR}/GUISupport/MFC/VTKMFCSettings.cmake")
IF(VTK_MFC_DELAYLOAD_VTK_DLLS)
VTK_MFC_ADD_DELAYLOAD_FLAGS(CMAKE_EXE_LINKER_FLAGS
vtkRendering.dll
vtkIO.dll
vtkFiltering.dll
vtkCommon.dll
)
ENDIF(VTK_MFC_DELAYLOAD_VTK_DLLS)
SET(SRCS
ChildFrm.cpp
MainFrm.cpp
Sample.cpp
Sample.rc
SampleDoc.cpp
SampleView.cpp
StdAfx.cpp
vtkMFCDocument.cpp
vtkMFCRenderView.cpp
vtkMFCView.cpp
res/Sample.rc2
)
ADD_EXECUTABLE(Win32SampleMFC WIN32 ${SRCS})
IF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC ${VTK_MFC_EXTRA_LIBS})
ENDIF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC vtkRendering)well, in VTK, version 6, I didn't have
vtkRendering.dll vtkIO.dll vtkFiltering.dll vtkCommon.dll
and I don't know how to adapt CMakeList.txt in order to compile the project ... and I got linking error:fatal error LNK1104: cannot open file 'vtkRendering.lib'
Also, I didn't have any
vtkRendering.lib
, justvtkRenderingCore-6.1.lib
Any help that you give, will be very appreciated ! -
Regor, kindly thank you. I am trying to compile their SampleMFC project, that has following CMakeList.txt:
cmake_minimum_required(VERSION 2.8)
PROJECT(Win32SampleMFC)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})This VTK_DIR usage only works in the VTK build tree...
Make it work in the "make install" tree, too.
INCLUDE("${VTK_DIR}/GUISupport/MFC/VTKMFCSettings.cmake")
IF(VTK_MFC_DELAYLOAD_VTK_DLLS)
VTK_MFC_ADD_DELAYLOAD_FLAGS(CMAKE_EXE_LINKER_FLAGS
vtkRendering.dll
vtkIO.dll
vtkFiltering.dll
vtkCommon.dll
)
ENDIF(VTK_MFC_DELAYLOAD_VTK_DLLS)
SET(SRCS
ChildFrm.cpp
MainFrm.cpp
Sample.cpp
Sample.rc
SampleDoc.cpp
SampleView.cpp
StdAfx.cpp
vtkMFCDocument.cpp
vtkMFCRenderView.cpp
vtkMFCView.cpp
res/Sample.rc2
)
ADD_EXECUTABLE(Win32SampleMFC WIN32 ${SRCS})
IF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC ${VTK_MFC_EXTRA_LIBS})
ENDIF(VTK_MFC_EXTRA_LIBS)
TARGET_LINK_LIBRARIES(Win32SampleMFC vtkRendering)well, in VTK, version 6, I didn't have
vtkRendering.dll vtkIO.dll vtkFiltering.dll vtkCommon.dll
and I don't know how to adapt CMakeList.txt in order to compile the project ... and I got linking error:fatal error LNK1104: cannot open file 'vtkRendering.lib'
Also, I didn't have any
vtkRendering.lib
, justvtkRenderingCore-6.1.lib
Any help that you give, will be very appreciated !Yes in VTK version 6 the naming convention for the libraries was changed. It is now part of the lib name, that is why you have a vtkRenderingCore-6.1.lib instead of vtkRendering.lib. It seems those changes did not make it in the cmake files of the example you're trying to use. Anyway when using cmake you shouldnt care about the concrete names of the libs since this is handled by the cmake configuration. I can show you how I succesfully link VTK 6.1 to one of my projects:
# Try to automatically detect VTK.
find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOLegacy vtkFiltersCore)
if(VTK_FOUND)
message(STATUS "Found package VTK. Using " ${VTK_USE_FILE})
include(${VTK_USE_FILE})
else(VTK_FOUND)
message(FATAL_ERROR "VTK not found. Please set VTK_DIR.")
endif(VTK_FOUND)target_link_libraries(myTarget ${VTK_LIBRARIES})
In your place I would start trying to build a basic VTK project (Hello World etc.) at first to see if this works. If you got this you can start to add simple MFC functionality. I did not use MFC with VTK myself so sadly I cannot share any experience about this combination.
-
Yes in VTK version 6 the naming convention for the libraries was changed. It is now part of the lib name, that is why you have a vtkRenderingCore-6.1.lib instead of vtkRendering.lib. It seems those changes did not make it in the cmake files of the example you're trying to use. Anyway when using cmake you shouldnt care about the concrete names of the libs since this is handled by the cmake configuration. I can show you how I succesfully link VTK 6.1 to one of my projects:
# Try to automatically detect VTK.
find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOLegacy vtkFiltersCore)
if(VTK_FOUND)
message(STATUS "Found package VTK. Using " ${VTK_USE_FILE})
include(${VTK_USE_FILE})
else(VTK_FOUND)
message(FATAL_ERROR "VTK not found. Please set VTK_DIR.")
endif(VTK_FOUND)target_link_libraries(myTarget ${VTK_LIBRARIES})
In your place I would start trying to build a basic VTK project (Hello World etc.) at first to see if this works. If you got this you can start to add simple MFC functionality. I did not use MFC with VTK myself so sadly I cannot share any experience about this combination.
-
Yes in VTK version 6 the naming convention for the libraries was changed. It is now part of the lib name, that is why you have a vtkRenderingCore-6.1.lib instead of vtkRendering.lib. It seems those changes did not make it in the cmake files of the example you're trying to use. Anyway when using cmake you shouldnt care about the concrete names of the libs since this is handled by the cmake configuration. I can show you how I succesfully link VTK 6.1 to one of my projects:
# Try to automatically detect VTK.
find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOLegacy vtkFiltersCore)
if(VTK_FOUND)
message(STATUS "Found package VTK. Using " ${VTK_USE_FILE})
include(${VTK_USE_FILE})
else(VTK_FOUND)
message(FATAL_ERROR "VTK not found. Please set VTK_DIR.")
endif(VTK_FOUND)target_link_libraries(myTarget ${VTK_LIBRARIES})
In your place I would start trying to build a basic VTK project (Hello World etc.) at first to see if this works. If you got this you can start to add simple MFC functionality. I did not use MFC with VTK myself so sadly I cannot share any experience about this combination.
Are you trying to say that I should put the above script into my
CMakeList.txt
? Ok, I put this script inside of CMakeList.txt, but I got an error:CMake Error at CMakeLists.txt:14 (target_link_libraries):
Cannot specify link libraries for target "myTarget" which is not built by
this project.I replace
myTarget
with my sample,Win32SampleMFC
... nothing worked ... -
Yes in VTK version 6 the naming convention for the libraries was changed. It is now part of the lib name, that is why you have a vtkRenderingCore-6.1.lib instead of vtkRendering.lib. It seems those changes did not make it in the cmake files of the example you're trying to use. Anyway when using cmake you shouldnt care about the concrete names of the libs since this is handled by the cmake configuration. I can show you how I succesfully link VTK 6.1 to one of my projects:
# Try to automatically detect VTK.
find_package(VTK REQUIRED COMPONENTS vtkIOGeometry vtkIOLegacy vtkFiltersCore)
if(VTK_FOUND)
message(STATUS "Found package VTK. Using " ${VTK_USE_FILE})
include(${VTK_USE_FILE})
else(VTK_FOUND)
message(FATAL_ERROR "VTK not found. Please set VTK_DIR.")
endif(VTK_FOUND)target_link_libraries(myTarget ${VTK_LIBRARIES})
In your place I would start trying to build a basic VTK project (Hello World etc.) at first to see if this works. If you got this you can start to add simple MFC functionality. I did not use MFC with VTK myself so sadly I cannot share any experience about this combination.