Missing dll on program startup - a way automate it?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Missing dll on program startup - a way automate it?

Klemen Ferjančič
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Missing dll on program startup - a way automate it?

Petr Kmoch
Hi.

I haven't used it yet, but I believe the target property https://cmake.org/cmake/help/latest/prop_tgt/VS_DEBUGGER_ENVIRONMENT.html might help you.

Petr

On Wed, 20 Nov 2019 at 01:02, cen <[hidden email]> wrote:
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Missing dll on program startup - a way automate it?

Michael Jackson
You can also use cmake to just copy the DLLs into the appropriate directory. Here is a snippet from our own projects.

#-------------------------------------------------------------------------------
#- This copies all the Prebuilt Pipeline files into the Build directory so the help
#- works from the Build Tree
add_custom_target(PrebuiltPipelinesCopy ALL
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${DREAM3D_SUPPORT_DIR}/PrebuiltPipelines
            ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/PrebuiltPipelines/
            COMMENT "Copying Prebuilt Pipelines into Binary Directory")
set_target_properties(PrebuiltPipelinesCopy PROPERTIES FOLDER ZZ_COPY_FILES)

--
Mike Jackson


-- 
Michael A. Jackson                 400 S. Pioneer Blvd
Owner, President                   Springboro, Ohio 45066
BlueQuartz Software, LLC           EMail: mailto:[hidden email]
Voice: 937-790-1601                Web: http://www.bluequartz.net/
Fax: 937-746-0783



From: CMake <[hidden email]> on behalf of Petr Kmoch <[hidden email]>
Date: Wednesday, November 20, 2019 at 3:32 AM
To: cen <[hidden email]>
Cc: CMake <[hidden email]>
Subject: Re: [CMake] Missing dll on program startup - a way automate it?

Hi.

I haven't used it yet, but I believe the target property https://cmake.org/cmake/help/latest/prop_tgt/VS_DEBUGGER_ENVIRONMENT.html might help you.

Petr

On Wed, 20 Nov 2019 at 01:02, cen <mailto:[hidden email]> wrote:
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by http://kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
-- Powered by kitware.com/cmake Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services Visit other Kitware open-source projects at https://www.kitware.com/platforms Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake This mailing list is deprecated in favor of https://discourse.cmake.org 


--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Missing dll on program startup - a way automate it?

fdk17
In reply to this post by Petr Kmoch
Adding the relevant directories to PATH in the debugger or build environment should allow them to be found. 

On Wed, Nov 20, 2019, at 3:32 AM, Petr Kmoch wrote:
Hi.

I haven't used it yet, but I believe the target property https://cmake.org/cmake/help/latest/prop_tgt/VS_DEBUGGER_ENVIRONMENT.html might help you.

Petr

On Wed, 20 Nov 2019 at 01:02, cen <[hidden email]> wrote:
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:

This mailing list is deprecated in favor of https://discourse.cmake.org
-- 

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org



--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Missing dll on program startup - a way automate it?

J Decker
Can also add install rules so you get an INSTALL target, and then you can just build that, and everything will end up in the right place.


On Thu, Nov 21, 2019 at 3:56 AM Fred Baksik <[hidden email]> wrote:
Adding the relevant directories to PATH in the debugger or build environment should allow them to be found. 

On Wed, Nov 20, 2019, at 3:32 AM, Petr Kmoch wrote:
Hi.

I haven't used it yet, but I believe the target property https://cmake.org/cmake/help/latest/prop_tgt/VS_DEBUGGER_ENVIRONMENT.html might help you.

Petr

On Wed, 20 Nov 2019 at 01:02, cen <[hidden email]> wrote:
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:

This mailing list is deprecated in favor of https://discourse.cmake.org
-- 


Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:

This mailing list is deprecated in favor of https://discourse.cmake.org


--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Missing dll on program startup - a way automate it?

Klemen Ferjančič
In reply to this post by Petr Kmoch

Thanks, this is exactly what I need.

Unfortunately constructing the path expansion involves some gymnastics. If Find* exposes a list of directories it's just a simple list join (-> boost) but if it does not it is more involved..

list(JOIN Boost_LIBRARY_DIRS ";" BOOST_PATH)

set(ZLIB_PATH "")
FOREACH(LIB_NAME ${ZLIB_LIBRARIES})
   get_filename_component(LDIR ${LIB_NAME} DIRECTORY)
   if (NOT ZLIB_PATH MATCHES "${LDIR}")
     set(ZLIB_PATH "${ZLIB_PATH};${LDIR}")
   endif()
ENDFOREACH()

set(EXPAND_PATH "${ZLIB_PATH};${BOOST_PATH}")
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%${EXPAND_PATH}")


Is there a way to get a list of all additional library directories? That would be ideal but I couldn't find anything.


On 11/20/19 9:32 AM, Petr Kmoch wrote:
Hi.

I haven't used it yet, but I believe the target property https://cmake.org/cmake/help/latest/prop_tgt/VS_DEBUGGER_ENVIRONMENT.html might help you.

Petr

On Wed, 20 Nov 2019 at 01:02, cen <[hidden email]> wrote:
Hi

Perhaps not really a cmake problem but here we go. An exe depends on a
few DLLs which I ship in the repo so the rest of the devs don't have to
build them or fetch them somewhere else. Cmake finds the libraries and
project builds just fine, until you run it from VS.. you are welcomed by
the "missing dll" windows error. So I have to copy all the dlls to the
build/run folder to make it work but this is a manual step. Is there
some way in cmake/VS to somehow tell the IDE to append the execution
$PATH with all the specified library dependencies or something along
those lines? Ideally my goal is to just run cmake, open VS, build the
project and run, all automagical.

I would prefer to keep the dynamic linking.


Best regards, cen

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org