How do I inform the debugger of the location of run-time linked DLL files? - c++

I have a C++ program that uses the freeglut library (and hence requires the freeglut.dll at run-time. I have added the folder C:\Program Files\Common Files\freeglut\bin to my PATH environment variable.
To confirm that the location is correct, when I compile my program (debug build) and run the resulting .exe file, it works fine (the freeglut.dll file is not in the same directory as the executable).
However, when I run the program directly from the VS2012 debugger, I get this message:
The program can't start because freeglut.dll is missing from your computer. Try reinstalling the program to fix this problem.
I know that one solution is to place the freeglut.dll file in the directory of the executable. This is what I've been doing so far, but I would much rather simply inform VS2012 (or my program) of where to find the dll file. Note that this post also seems loosely related, but it doesn't seem to contain an answer relevant to what I am trying to achieve (I just want the debugger to look in the same place for DLLs as any other program!).
How do I achieve this in VS2012? Icing on the question cake would be an explanation as to why the debugger doesn't just look in the PATH variable like any other program...

You can also set project based Environment:
Open project Properties
Go to Configuration Properites -> Debugging
Enter the path in Environment, eg:
PATH=$(PATH);C:\Program Files\Common Files\freeglut\bin

Restart Visual Studio after modifying your PATH variable.
What I did actually worked. I just didn't restart VS...

Related

How to fix "libopenblas.dll was not found" system error on visual studio C++?

I want to use the armadillo library in my C++ code. I downloaded it, and copied both the "include" and "lib_win64" folders into a new folder in my solution folder called "Dependencies".
The include folder contained another folder within which contained all the header files.
The lib_win64 folder contained "libopenblas.dll" and "libopenblas.lib".
Now, I opened up my C++ program in visual studio, went into project properties and changed these:
I added $(SolutionDir)Dependencies\armadillo\include in the C++->general->Additional include directories field
I added $(SolutionDir)Dependencies\armadillo\lib_win64 in the Linker->general->Additional library directories field
I lastly added libopenblas.lib to the Linker->input->Additional dependencies field
The C++ program builds successfully, but when I try to run it, I receive the system error: "The code execution cannot proceed because libopenblas.dll was not found. Reinstalling the program may fix this problem."
The initial armadillo download folder contains other folders, one being an example C++ program. I run that and it compiles and executes as it should, with no system error. So, I don't think the .dll file is corrupted or anything.
I was wondering if someone has maybe had a similar issue, or knows somewhere I may have messed up and can point it out.
Any advice would be much appreicated!

visual studio 2013 modify path variable when running .exe

I have compiled an exe file in Visual Studio 2013, and it depends on some external files to function. I want to keep those files in the same folder that the exe is in. When I run the .exe by clicking on it in file explorer, it loads the files fine. However, when I run it from Visual Studio, it is unable to run because the PATH variable does not include the directory with the necessary files. How can I configure my project to run the program with a modified path variable so that it can access the files properly?
As far as I understand you question correctly. I suspect that this is an issue related to the different directories when you execute. In Visual Studio (to my knowledge), you have a folder named Debug and a second folder named Release.
You may choose in Visual Studio to run the program in either debug or release mode. But you might not have the required files neccessary in both directories.
For example:
I've made a program that reads "Hello World!" from hello.txt, and displays this in the dialog window as a string.
If I store the file in the Release directory, the executable will run fine outside the IDE, when just launching the executable file.
However, if you run the application in debug mode through the IDE (Visual Studio), the program will not find the neccessary file. The program is looking for the file in it's current directory (Debug).
A quick fix to this is to copy the required files to the current working directory. Eventually have a duplicate set of files in both directories at all times.
Hope that I did understand you correct, and that my answer helps you. :)

visual studio 2013 deploy a project

I crack my head already, I need to deploy a project. I tried to use InstallShield, it create an msi file, and local installation has no errors, but then when I tried to launch the program it output "debug error". In my settings code generator -> runtime library set for Multi-threaded Debug DLL(/MDd). If I'll set it to Multi-threaded (/MT) it would not compile: "Please use the /MD switch for _AFXDLL builds"
Then I tried to use VS Installer project extension. It creates the msi and setup file, but after I install it, I can't find the .exe file and launch program. What I am doing wrong?
Folder with project files
![enter image description here][3]
Folder with exe file
![enter image description here][4]
At the stage of creating the installer for your program, you have to put all the external files, libraries and resources, that your program needs in order to run correctly, in your program's working directory. When you run the program via Visual Studio, everything works fine since it can find the files, because, as you've mentioned, they are in the project folder, and the project folder is where Visual Studio is looking for them.
When you launch your program outside VS, the program can't find these files since it by default tries to locate them in the folder in which the .exe file being run is located. So, if you wan't to run program outside VS, you need to put all the files needed to your .exe's directory.
For the same reason, while creating your installer, you need to include all the files necessary in the installation target directory together with your .exe. Every installer creator lets you do that.
In general, if you cannot run your program outside any IDE, and you can run it within that IDE, it is a rule of thumb that you should first check if you have included all the necessary files/libraries/dll's/etc. in your program's working directory.
I solved it!!!!!!!!
1)Help to run .exe file, helped updating .uld file in the same directory as a exe file.
2)I used Dependency Walker (http://www.dependencywalker.com/) to find all dll that it's need. And then I create a Setup Project using Wizard at the "Choose file to include" step I add every file and every library that it's depend on! Build->Install-> Then magic, and my application installed and running! Thank you all for your help

SDL.dll is missing from my computer - VS 2010

I'm trying to compile a SDL-program I've written, but when I do, this error shows up:
The program can't start because SDL.dll is missing from your computer.
Try reinstalling the program to fix this problem
I have no idea as to why. I have SDL.dll.
I have put it in the correct folder: C:\Windows\System32.
I have the correct PATHS to all the SDL headers and such as well.
VS says:
Build succeeded: 1
and THEN the error above pops up on screen.
Add it into your debug folder or whatever directory your program is currently located at.
SDL.dll has to either be in the same directory as your application, or in a directory that's in the PATH environment variable.
IfSDL.dll is 32-bit and you're running a 64-bit system you have to place the dll into /Windows/SysWOW64/ rather than /Windows/System32/, which is used for 64-bit dlls.
EDIT:
You probably shouldn't be deploying your DLLs by copying them into the System32 directory, unless they're common libraries that are used by several applications, and even then I would use discretion. For example, an application could update the DLL, which could break other applications that rely on an older version of the library.
Instead, copy the DLLs into the same directory that the executable is being built in. If you're building and executing with Visual Studio it will look for the DLL in the Project directory, where your source files are probably located.
Just place your SDL.dll in the same folder and your problem will be solved.
And to answer to your problem with the PATH, you can specify in visual studio where he will look for executables while debugging. Maybe this isn't set correctly and that's why VS can't find SDL.dll?

freeglut.dll missing

I am reading the OpenGl superbible, and on the very first triangle program it will not run.
the program compiles just fine but when i run it, it gave me the error message freeglut.dll is missing from your computer. I downloaded that and put it in the correct directory, and it said that MSVCR71.dll was missing, so i downloaded that and put it in the correct directory and it began to say "The procedure entry point __glutCreateWindowWithExit could not be located in the dynamic link library freeglut.dll." does anyone know what i am doing wrong? i followed all the directions that the book told me.
You can't just grab random DLLs off the interwebtubes and dump them on your PC. There are versioning issues to consider that you're completely bypassing. It should have been a hint when the MSVC runtime dependency didn't link up.
Install the freeGLUT package properly, in its entirety.
I have had the same problem. Follow these steps:
Assuming that you have performed all steps given in the book.
Download the source code from companion siteā€¦I think the folder is SB5 and its 92 MB.
Then build the project named 'freeglut.vcproj'.
It will produce freeglut.dll apart from other files.Put freeglut.dll into c:\windows\syswow64 folder and all is done.
You could just include the dll wherever your executable is, if you are running this MSVC, then you could for example put the dll inside of your Debug folder. Cleaning the folder would remove everything except that dll so you wouldnt have to worry about constantly recopying it. Furthermore, if you want an alternative solution you could just put the dll inside of you Windows/System32 folder, or in the case of 64 bit architectures you could put it inside of the System/SysWow64 folder
The freeglut.dll should be placed in the VS project folder. The dll is part of the MSVC package - http://www.transmissionzero.co.uk/software/freeglut-devel/
Isn't there any options on the compiler where you can link the libraries? For example, if you use DevC++, you should go to Project -> Project Options -> Parameters, and set the Linkers.