Search code examples
c++visual-studioportaudio

Portaudio.dll won't link properly in VS


I'm using C++ on visual studio 2019 and having issues trying to link my project to PortAudio. I'm getting the error 'portaudio_x64.dll was not found. Reinstalling the program may fix this problem'. I have linked to portaudio.lib in Properties->Configuration properties->linker->Input->Additional dependencies. I have also put the folder in which the .lib file lives in Properties->Configuration properties->Linker->General->Additional library directories. The path to the folder where portaudio.h lives is in Properties->Configuration properties->C/C++->General->Additional include directories. For good measure I have tried compiling both with the portaudio.h file in my header files tab, and without. Someone here suggested that I copy the actual dll file into the same folder as my solution. This works when I run the program with Crtl+F5, but when I build the solution and open the exe, I get the same error as before. I'm really struggling to see the issue, any help would be great Additional include directoriesAdditional library directoriesAdditional dependencies


Solution

  • A DLL used by an EXE needs to be in the same directory as the EXE runs from (your current working directory), or on the system PATH (which includes places like C:\Windows\System32\).

    Someone here suggested that I copy the actual dll file into the same folder as my solution. This works when I run the program with Crtl+F5

    The current working directory set by Visual Studio during debugging is your solution folder.

    but when I build the solution and open the exe, I get the same error as before

    You're not using Visual Studio here: the current working directory is wherever you're opening the EXE from. If that's in Explorer, it's probably the folder the EXE resides in. If that's in cmd.exe, it's wherever you have navigated to!

    Ideally, you'd keep the DLL in your solution folder, but add it as a dependency or resource in your project, so that it gets copied to the same place as your EXE on build.