0

I am trying to link my .exe file to a .dll in visual studio but I don't understand how (I am using VS2019). I have looked at this question here but it only provides half the solution. I went to project properties->debugging->Environment and added PATH=LOCATION_OF_MY_DLL and this works when I run the program in the IDE, but when I manually run the .exe it gives the same error that the dll was not found (it is only fixed if I copy the dll to the exe location).

In addition, I am managing the entire project using premake so is there a way to add these setting in there as well?

Ak01
  • 362
  • 3
  • 19
  • 1
    ***but when I manually run the .exe it gives the same error that the dll was not found (it is only fixed if I copy the dll to the exe location).*** You need to set the PATH environment variable in your OS for that or copy the required dll to the same location as the executable. There are other options listed in this Microsoft help page: [https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications) – drescherjm Jan 28 '22 at 15:55
  • 1
    You have pretty much answered your own question. The OS will not hunt down the location of DLLs. as drescherjm points out, you have to tell it where the DLL is. Create a lib folder and put your DLLs there, with PATH set. Then they will be available for all your projects. If the .lib and .pdb files are generated in that folder, `Output Directory`, then you have it all, debugging into the DLLs will work. – lakeweb Jan 28 '22 at 16:01
  • @lakeweb can you explain what you mean by debugging into dll? Also, does this mean that there is no way for us to automate this so that if I send my project to someone and they build it, it will work without them having to move the dll or set the PATH? – Ak01 Jan 28 '22 at 16:33
  • This may help (part about post build command): [https://github.com/premake/premake-core/issues/1293](https://github.com/premake/premake-core/issues/1293) – drescherjm Jan 28 '22 at 17:02
  • Hi, so, are these dll's ones that you compile? As far as deployment to other machines, you would have to include the dlls in the package. If they are only meant for your app, it is fine if they go into the same directory, no PATH needed. And if you only have one app, you really don't need dlls, just link to libs. which means building libs instead of dlls. If set up properly, when you 'step into' a dll function, it just works. – lakeweb Jan 31 '22 at 21:03

0 Answers0