DLL dependency not found when debugging with Visual Studio 11 RC

放肆的年华 提交于 2020-01-11 04:29:25

问题


My project is a standalone C++ application that uses FMOD for playing sound. I've previously developed the same project with Visual Studio 2010 without any problems, but 2012 gives me the classic error: "The program can't start because fmodex.dll is missing from your computer. Try reinstalling the program to fix this problem." The project seems to load other DLLs(such as Direct3d related files and d3d shader compiler) just fine.

The problem occurs only if trying to debug or run the program from the IDE, not if I copy the executable to the appropriate directory with DLL and run it manually. If I remove all references to FMOD from the program, the debugging and running works fine. I've made sure that I have correct working directory in Project settings (besides it loads all the other files just fine in the same directory). I originally converted the project from Visual Studio 2010, but tried to create a new project from scratch with no luck. I've also tinkered all the possible compiler and linker settings through, and googling doesn't seem to help either.

I'm guessing that the problem has something to do with the new Metro style apps and it's way to handle external dependecies, but I have also turned "Metro Style App Support" off. I'm starting to think I've really tried everything I can and have no idea what to try next. Directions for getting more diagnostic information would be much appreciated as well! Thanks!

Edit: Visual Studio version I'm using is Visual Studio Ultimate 2012 RC, Version 11.0.50706.0 QRELRC July, 2012


回答1:


Go to the project's properties:

Configuration Properties | Debugging | Environment 

And add the following item:

PATH=c:\path\where\the\dll-is;$(Path)



回答2:


My sympathies, I live in DLL hell a lot lately it seems. Two suggestions:

  1. You can drive the IDE from the command line with devenv which has a /useenv switch.

    "... Use PATH, INCLUDE, LIBPATH, and LIB environment variables instead of IDE paths for VC++ builds.

  2. dumpbin /dependents [*.exe] [*.dll] will show you DLL dependencies.

    dumpbin /dependents openssl.exe

Microsoft (R) COFF/PE Dumper Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file openssl.exe

File Type: EXECUTABLE IMAGE

Image has the following dependencies:

SSLEAY32.dll
LIBEAY32.dll
WSOCK32.dll
MSVCR80.dll
KERNEL32.dll

Summary

     4000 .data
    14000 .rdata
     1000 .rsrc
    33000 .text 



回答3:


It may be that VS is running the app with a different current directory to when you run the app by hand.

VS typically sets the current directory to the project folder, which is usually not the same as the folder where the built binaries are. When you run it by hand you're probably running it from the latter, not the former.

If that is the problem then the code that loads fmodex.dll must be depending on the current dir being in the DLL search path, which can a big security risk (lookup "DLL planting" or DLL "pre-loading") and which is actively blocked by some Windows configurations.



来源:https://stackoverflow.com/questions/12518082/dll-dependency-not-found-when-debugging-with-visual-studio-11-rc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!