Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. If I use a library, do I need DLL file ?

If I use a library, do I need DLL file ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhelp
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    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 ?

    _ L 2 Replies Last reply
    0
    • _ _Flaviu

      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 ?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      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)

      Polymorphism in C

      A 1 Reply Last reply
      0
      • _ _Superman_

        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)

        Polymorphism in C

        A Offline
        A Offline
        AssemToCode
        wrote on last edited by
        #3

        I want to know the details of linker,do you have any suggestion?

        1 Reply Last reply
        0
        • _ _Flaviu

          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 ?

          L Offline
          L Offline
          Legor
          wrote on last edited by
          #4

          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.

          _ 1 Reply Last reply
          0
          • L Legor

            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.

            _ Offline
            _ Offline
            _Flaviu
            wrote on last edited by
            #5

            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 ....

            L 1 Reply Last reply
            0
            • _ _Flaviu

              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 ....

              L Offline
              L Offline
              Legor
              wrote on last edited by
              #6

              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.

              _ 1 Reply Last reply
              0
              • L Legor

                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.

                _ Offline
                _ Offline
                _Flaviu
                wrote on last edited by
                #7

                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, just vtkRenderingCore-6.1.lib Any help that you give, will be very appreciated !

                L 1 Reply Last reply
                0
                • _ _Flaviu

                  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, just vtkRenderingCore-6.1.lib Any help that you give, will be very appreciated !

                  L Offline
                  L Offline
                  Legor
                  wrote on last edited by
                  #8

                  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.

                  _ 3 Replies Last reply
                  0
                  • L Legor

                    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.

                    _ Offline
                    _ Offline
                    _Flaviu
                    wrote on last edited by
                    #9

                    Ok, thank you, right now I should leave the office, but tomorrow I will write you what I have done ... see you soon. :)

                    1 Reply Last reply
                    0
                    • L Legor

                      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.

                      _ Offline
                      _ Offline
                      _Flaviu
                      wrote on last edited by
                      #10

                      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 ...

                      1 Reply Last reply
                      0
                      • L Legor

                        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.

                        _ Offline
                        _ Offline
                        _Flaviu
                        wrote on last edited by
                        #11

                        Finnaly I make it .. .thank you for all your support ! See you.

                        L 1 Reply Last reply
                        0
                        • _ _Flaviu

                          Finnaly I make it .. .thank you for all your support ! See you.

                          L Offline
                          L Offline
                          Legor
                          wrote on last edited by
                          #12

                          Congratulations! Cmake configuration may be nerve-wrecking (and often are imo ;) ). See you

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups