The "portaudio_x86.lib" which you obtained in the previous stage is a library, so you can develop applications invoking functions defined in that library.
Let's write a simple program which invokes Pa_GetVersion() and Pa_GetVersionText():
#include <stdio.h> #include "portaudio.h" int main() { printf("%x\n%s\n", Pa_GetVersion(), Pa_GetVersionText()); return 0; }
In Visual Studio, press Ctrl-Shift-N to create a new project "PA01" (which stands for "PortAudio 01") as an "Empty Project". Because this solution only consists of a project, you don't need to check "Create directory for solution".
Press Ctrl-Shift-A to add a new item in "Source Files". You may choose an arbitrary filename, or choose a filename which is the same as the project name ("pa01.cpp").
Copy and paste the above code into the editor. Now it still cannot be compiled sucessfully, because Visual C++ doesn't know where to include "portaudio.h".
Project - Properties - C/C++ - General - Additional Include Directories
Click the "pa01.cpp" file and press Ctrl-F7 to compile. This time it is compiled successfully. A file "PA01.OBJ" is generated under "source/repos/PA01/Debug".
Try to "build" the project by clicking Ctrl-Shift-B. This will try to link "PA01.OBJ" with the PortAudio library. However, it complains "unresolved external symbol" because Visual C++ has no idea about which library to link. You must specify "portaudio.lib" as the external library to link.
In "Solution Explorer", click the project "PA01" (not the solution, not the pa01.cpp file).
Now Ctrl-Shift-B should build the project successfully and generate an executable file "PA01.EXE" under "source/repos/PA01/Debug", too.
Running the "PA01.EXE" program will cause an error, because it fails to find "portaudio.dll".
The simplest solution is to copy your "portaudio_x86.dll" to the same directory as PA01.EXE. Now you can run "PA01.EXE" successfully.
- If you prefer to run the program by Ctrl-F5 directly in Visual Studio, put "portaudio_x86.dll" in the "PA01" directory (this is where "pa01.cpp" resides) instead of "PA01/Debug".