title: Building C project with PortAudio
body: <p>I decided to port my audio project to C and succeeded with using SDL library. I'd like to use ASIO, which is provided by PortAudio, so I built PortAudio with ASIO support without errors. When I include portaudio.h, add library -lportaudio to linker, build everything and run, there is no problem. But when I try to call any of the portaudio functions (<code>Pa_Initialize</code>, for example), I get this output:</p>
  
  <pre><code>08:27:54 **** Incremental Build of configuration Debug for project PortAudioTest ****
  Info: Internal Builder is used for build
  gcc -O0 -g3 -Wall -c -fmessage-length=0 -o main.o "..\\main.c"
  gcc -o PortAudioTest.exe main.o -lportaudio
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_util.o): In function `PaUtil_GetTime':
  D:\Dokumenty\Downloads\portaudio/src/os/win/pa_win_util.c:148: undefined reference to `timeGetTime@0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `AdvanceToNextOutputBuffer':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2733: undefined reference to `waveOutWrite@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2739: undefined reference to `waveOutGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `AdvanceToNextInputBuffer':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2706: undefined reference to `waveInAddBuffer@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2712: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `StopStream':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3538: undefined reference to `waveOutReset@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3542: undefined reference to `waveOutGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3551: undefined reference to `waveInReset@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3555: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `ProcessingThreadProc':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2968: undefined reference to `waveOutGetPosition@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `TerminateWaveHeaders':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2099: undefined reference to `waveInUnprepareHeader@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2101: undefined reference to `waveOutUnprepareHeader@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `QueryOutputWaveFormatEx':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:543: undefined reference to `waveOutOpen@24'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:559: undefined reference to `waveOutGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `QueryInputWaveFormatEx':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:517: undefined reference to `waveInOpen@24'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:533: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `InitializeWaveHeaders':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2049: undefined reference to `waveInPrepareHeader@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2059: undefined reference to `waveOutPrepareHeader@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:2063: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `AbortStream':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3597: undefined reference to `waveOutReset@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3600: undefined reference to `waveOutGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3610: undefined reference to `waveInReset@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3613: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `StartStream':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3235: undefined reference to `waveInAddBuffer@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3239: undefined reference to `waveInGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3252: undefined reference to `waveOutPause@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3327: undefined reference to `waveOutGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3323: undefined reference to `waveOutWrite@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3388: undefined reference to `waveInStart@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3393: undefined reference to `waveInGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3403: undefined reference to `waveOutRestart@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:3406: undefined reference to `waveOutGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `TerminateWaveHandles':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1940: undefined reference to `waveInClose@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1958: undefined reference to `waveInGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1947: undefined reference to `waveOutClose@4'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1962: undefined reference to `waveOutGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `InitializeWaveHandles':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1860: undefined reference to `waveInOpen@24'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1910: undefined reference to `waveOutGetErrorTextA@12'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1866: undefined reference to `waveOutOpen@24'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:1906: undefined reference to `waveInGetErrorTextA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `PaWinMme_Initialize':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:976: undefined reference to `waveInMessage@16'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:980: undefined reference to `waveOutMessage@16'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:984: undefined reference to `waveInGetNumDevs@0'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:988: undefined reference to `waveOutGetNumDevs@0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `InitializeInputDeviceInfo':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:692: undefined reference to `waveInGetDevCapsA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `InitializeOutputDeviceInfo':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:820: undefined reference to `waveOutGetDevCapsA@12'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_wmme.o): In function `PaWinMme_Initialize':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c:988: undefined reference to `waveOutGetNumDevs@0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o): In function `Terminate':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1409: undefined reference to `operator delete(void*)'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o): In function `GetStreamTime':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:3538: undefined reference to `timeGetTime@0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o): In function `PaAsio_Initialize':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1382: undefined reference to `operator delete(void*)'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1216: undefined reference to `operator new(unsigned int)'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1216: undefined reference to `operator delete(void*)'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1218: undefined reference to `__cxa_get_exception_ptr'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o): In function `bad_alloc':
  c:/mingw/lib/gcc/mingw32/4.8.1/include/c++/new:54: undefined reference to `vtable for std::bad_alloc'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o): In function `PaAsio_Initialize':
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1218: undefined reference to `__cxa_begin_catch'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1218: undefined reference to `std::bad_alloc::~bad_alloc()'
  D:\Dokumenty\Downloads\portaudio/src/hostapi/asio/pa_asio.cpp:1218: undefined reference to `__cxa_end_catch'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o):pa_asio.cpp:(.rdata$_ZTISt9exception[__ZTISt9exception]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o):pa_asio.cpp:(.rdata$_ZTISt9bad_alloc[__ZTISt9bad_alloc]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_asio.o):pa_asio.cpp:(.eh_frame+0x6f7): undefined reference to `__gxx_personality_v0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_coinitialize.o): In function `PaWinUtil_CoInitialize':
  D:\Dokumenty\Downloads\portaudio/src/os/win/pa_win_coinitialize.c:79: undefined reference to `CoInitialize@4'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(pa_win_coinitialize.o): In function `PaWinUtil_CoUninitialize':
  D:\Dokumenty\Downloads\portaudio/src/os/win/pa_win_coinitialize.c:139: undefined reference to `CoUninitialize@0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTI8IUnknown[__ZTI8IUnknown]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTI5IASIO[__ZTI5IASIO]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTI21IASIOThiscallResolver[__ZTI21IASIOThiscallResolver]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV8IUnknown[__ZTV8IUnknown]+0x8): undefined reference to `__cxa_pure_virtual'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV8IUnknown[__ZTV8IUnknown]+0xc): undefined reference to `__cxa_pure_virtual'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV8IUnknown[__ZTV8IUnknown]+0x10): undefined reference to `__cxa_pure_virtual'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV5IASIO[__ZTV5IASIO]+0x8): undefined reference to `__cxa_pure_virtual'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV5IASIO[__ZTV5IASIO]+0xc): undefined reference to `__cxa_pure_virtual'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(iasiothiscallresolver.o):iasiothiscallresolver.cpp:(.rdata$_ZTV5IASIO[__ZTV5IASIO]+0x10): more undefined references to `__cxa_pure_virtual' follow
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiodrivers.o): In function `Z14loadAsioDriverPc':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/asiodrivers.cpp:11: undefined reference to `operator new(unsigned int)'
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/asiodrivers.cpp:11: undefined reference to `operator delete(void*)'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiodrivers.o):asiodrivers.cpp:(.eh_frame+0xff): undefined reference to `__gxx_personality_v0'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiolist.o): In function `deleteDrvStruct':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:111: undefined reference to `operator delete(void*)'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiolist.o): In function `newDrvStruct':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:75: undefined reference to `operator new[](unsigned int)'
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:80: undefined reference to `CLSIDFromString@8'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiolist.o): In function `ZN14AsioDriverListC2Ev':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:157: undefined reference to `CoInitialize@4'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiolist.o): In function `ZN14AsioDriverList14asioOpenDriverEiPPv':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:184: undefined reference to `CoCreateInstance@20'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libportaudio.a(asiolist.o): In function `ZN14AsioDriverListD2Ev':
  C:/MinGW/msys/1.0/asio/ASIOSDK/host/pc/asiolist.cpp:164: undefined reference to `CoUninitialize@0'
  collect2.exe: error: ld returned 1 exit status
  
  08:27:55 Build Finished (took 858ms)
  </code></pre>
  
  <p>I use 32bit MinGW with Eclipse on Windows 10 64bit.</p>
  
  <p>I also do not really understand, why portaudio headers from <code>D:\Dokumenty\Downloads\portaudio</code> are being used. When building with MSYS, I used <code>./configure --prefix=/mingw</code>, libraries and includes are present in my MinGW directories.</p>
  
  <p>Thanks in advance for any hints.</p>