Ricardo Valdez
Ricardo Valdez

Reputation: 25

Deployment of Visual Studio projects

My question is simple, how do i deploy or publish my Visual Studio project that is linked with an external library specifically, the OpenCV library. And that it can be run in other computers

Upvotes: 2

Views: 146

Answers (1)

skratchi.at
skratchi.at

Reputation: 1151

DLLs are very carefully to handle with. As you mentioned in your comment, you should place it right next to your executable.

Windows searches in several locations for your DLLs. In System folders and so on and in the folder where your executable is placed. For portability to other systems and to avoid, that windows uses the wrong DLL, you should place it along side your executable.

This LINK states:

The standard DLL search order used by the system depends on whether safe DLL search mode is enabled or disabled. Safe DLL search mode places the user's current directory later in the search order.

...

If SafeDllSearchMode is enabled, the search order is as follows:

  1. The directory from which the application loaded. 2.The system directory. Use the GetSystemDirectory function to get the path of this directory.
  2. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
  3. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  4. The current directory.
  5. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

If SafeDllSearchMode is disabled, the search order is as follows:

  1. The directory from which the application loaded.
  2. The current directory.
  3. The system directory. Use the GetSystemDirectory function to get the path of this directory.
  4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
  5. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

If it is possible you should define your DLL with an absolute path. Just for completeness. Also from the link:

A system can contain multiple versions of the same dynamic-link library (DLL). Applications can control the location from which a DLL is loaded by specifying a full path or using another mechanism such as a manifest.

As mentioned in the comments, you have to include the MVS run-time DLLs as well.

Upvotes: 1

Related Questions