Missing xxx.dll when performing built executives in visual studio - c++

The system warned that missing opencv_core331.dll
However, I have added the path of directory that include opencv_core331.dll to the environment variables of Windows:
Who can help?

This is a run-time issue, the libraries path has nothing to do with it. You need to either edit the global PATH variable or the executable directories in the project properties. I would personally recommend the global PATH variable because that way your program will run outside of VS as well as from it.
To do so, in the start menu search box type "environment" and select the ""Edit system environment variables" if you want to make the change for all accounts.environment variables for your account" or (

Related

How do i link libstdc++, libwinpthread, and libgcc to my visual studio project? [duplicate]

This question already has answers here:
How do I set the path to a DLL file in Visual Studio?
(7 answers)
Closed 7 years ago.
In Visual Studio 2010, under VC++ Directories > Executable Directories, I have specified the path to glew32d.dll. However, when I run the executable, it still complains.
On the other hand, if I copy the DLL into the local folder and run the executable then, it doesn't complain.
Can someone please tell me how to fix this? Also, why is Visual Studio not recognizing that path?
Update
Scenario: I currently use a template project which I use as a starter code for a lot of my projects. This template depends on glew32d.dll. I usually store all dependent dlls in a common bin folder. I was hoping to reference this folder and Visual studio could read the dlls from there, instead of me having to copy the dlls everytime. What would be a good way to handle this?
Specifying the path to the DLL file in your project's settings does not ensure that your application will find the DLL at run-time. You only told Visual Studio how to find the files it needs. That has nothing to do with how the program finds what it needs, once built.
Placing the DLL file into the same folder as the executable is by far the simplest solution. That's the default search path for dependencies, so you won't need to do anything special if you go that route.
To avoid having to do this manually each time, you can create a Post-Build Event for your project that will automatically copy the DLL into the appropriate directory after a build completes.
Alternatively, you could deploy the DLL to the Windows side-by-side cache, and add a manifest to your application that specifies the location.
I've experienced same problem with same lib, found a solution here on
SO:
Search MSDN for "How to: Set Environment Variables for Projects".
(It's Project>Properties>Configuration Properties>Debugging
"Environment" and "Merge Environment" properties for those who are in
a rush.)
The syntax is NAME=VALUE and macros can be used (for example,
$(OutDir)).
For example, to prepend C:\Windows\Temp to the PATH:
PATH=C:\WINDOWS\Temp;%PATH%
Similarly, to append $(TargetDir)\DLLS to the PATH:
PATH=%PATH%;$(TargetDir)\DLLS
(answered by Multicollinearity here: How do I set a path in visual studio?
try "configuration properties -> debugging -> environment" and set the PATH variable in run-time
To add to Oleg's answer:
I was able to find the DLL at runtime by appending Visual Studio's $(ExecutablePath) to the PATH environment variable in Configuration Properties->Debugging. This macro is exactly what's defined in the Configuration Properties->VC++ Directories->Executable Directories field*, so if you have that setup to point to any DLLs you need, simply adding this to your PATH makes finding the DLLs at runtime easy!
* I actually don't know if the $(ExecutablePath) macro uses the project's Executable Directories setting or the global Property Pages' Executable Directories setting. Since I have all of my libraries that I often use configured through the Property Pages, these directories show up as defaults for any new projects I create.

Setting up bazel as an environment variable windows

I've been trying to use bazel on Windows 10 Pro, and I was following the instructions located at https://docs.bazel.build/versions/3.7.0/install-windows.html
I found the place to add user-specific and system-wide environment variables, and I added the path to bazel.exe and called the variable bazel, but when I try to type bazel into a command prompt window, it still isn't recognized.
Let me know if you need any more detail to help answer my question, I'm confused where I'm going wrong.
I think that you have to add the bazel binary path to your 'path' environment variable.
So search for Edit system environment variables -> Advanced -> Environment variables
and then under System Variables -> path -> edit you can add the path of your bazel bin (C:\User\Panda\Documents) and it should work. Detailed description with screenshots it's here: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/
You are trying to use bazel as a command, not as an environment variable. When you want to use the value of an environment variable, you need to surround the name in %s, ie:
C:\Users\Panda>%bazel% version
UPDATE: otherwise, since the .exe file you want to execute is also named bazel, it can be executed as a command, you would just need to add the path to bazel.exe's installation folder (C:\Users\Panda\Documents) to your system's %PATH% environment instead 1, as #Fed's answer explained, and then you can execute bazel normally:
C:\Users\Panda>bazel version
1: I don't recommend installing apps in your user profile's Documents folder! You should create a new folder for installing bazel into, preferrably under C:\Program Files (64bit) or C:\Program Files (x86) (32bit). Then you can add %ProgramFiles%\bezel\ to your %PATH% environment.

Linking to DLL via registry key ignored during debugging in Visual Studio

I'm working in VS 2019 on a C++ program in which I want to link into a bunch of 3rd party dlls, which are located in a folder separate from my executable. I don't want to copy all the dlls into the executable folder and have found the following solution.
Just like in the solution, I create a registry entry to define the keys with the information about the executable and the required path information to link to the DLLs:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyExe.exe
%Path2MyExe%\MyExe.exe (default key)
Path = %Path2DLLs%
The compilation from within VS works fine and when I start the generated executables from outside VS by (a) double clicking or (b) by using the command line, the 3rd party DLLs are found and the program is executed as expected.
However, when I invoke the debugger from within Visual Studio (c), execution is halted right away complaining that DLLs cannot be found.
I have checked the present working directory from within the code using _getcwd and for all options (a-c) it indicates the same directory.
So the question is: why does option (c) - debugging from within VS - not work?!
Cheers, Sebastian
It's probably because the executable that's launched when debugging is a vshost executable, not the generated executable for the project, and so it needs a separate entry in the registry.
If you want to stick with this kind of a build (highly not recommended), the easiest way to debug is to disable the hosting process:
Following the suggestion by drescherjm I tried to prepend the DLL directory to the PATH variable in "Configuration Properties -> Debugging -> Environment" following this solution.
However, this did not work for me. I also added the path directly in the system environment dialogue without success.
What did work in the end is setting the working directory under "Configuration Properties -> Debugging -> Working Directory" to point to the DLL folder. Now all three calling routes (a-c) work as expected.
Thanks to everyone for taking the time to help me out on this.
Sebastian

Make host application to see .so library while debugging

Trying to debug .so library from Eclipse C++ project under Linux. I have selected host application, but unfortunately host application is trying to find library in projects directory and not in Debug folder under it. And even I place host app in Debug folder it still search in project root folder. How to solve this problem?
Try to change the "Working directory" option under the "Arguments" tab of the debug configuration.
In general, in Linux the libraries are normally searched in LD_LIBRARY_PATH (which you can also try to override under the "Environment" tab but beware to keep the standard library paths there as well). And to load a so library from the current working dir, the LD_LIBRARY_PATH needs to contain the dot '.' path (which is not always the case - sometimes it is not included for security reasons).
Go to "Debug Configurations" from the pull-down here:
Then select your program in the left hand list and on the right select the "Environment" tab.
There you need to add a new environment variable called LD_LIBRARY_PATH. Its value should be the path to your library. If you have more than one library add their paths in a colon : separated list.

VS2010 change Path Macro

Hi I have a VS2010 projekt witch i moved from one machine to another. And on the new machine the QT installation is in a different place.
Now the projekt canĀ“t find the QT headers and libs. When i look in the projekt properties I see that all QT path are set with the makro $(QTDIR) and this path is the path of the old machine.
Is there any way to change the value of the makro?
THX for help
There is such thing as User Macros in VS 2010. It can be defined in Property Sheets. To find it you should open View->Property Manager panel, and there you'll see your projects and configurations. It will look like this:
In my project, I have a foldernames property sheet, in QT the name might be different. So you should right-click the property sheet and you'll see User macros page under Common properties:
Check there for your QTDIR macro.
I believe QTDIR is system/user variables that you need to define on your Windows.
You can take a look at : http://support.microsoft.com/kb/310519 that explain how to set the value.
Or, you can take a look at: http://www.itechtalk.com/thread3595.html
Once you set the variable, you may need to restart visual studio
To check if the variable has been set, type the following in command prompt:
echo %QTDIR%