gpt4 book ai didi

c - 使用 PortAudio 构建 C 项目

转载 作者:太空宇宙 更新时间:2023-11-04 04:33:24 25 4
gpt4 key购买 nike

我决定将我的音频项目移植到 C 并成功使用 SDL 库。我想使用 PortAudio 提供的 ASIO,所以我构建了支持 ASIO 的 PortAudio,没有出现错误。当我包含 portaudio.h 时,将库 -lportaudio 添加到链接器,构建所有内容并运行,没有问题。但是,当我尝试调用任何 portaudio 函数(例如 Pa_Initialize)时,我得到以下输出:

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)

我在 Windows 10 64 位上使用 32 位 MinGW 和 Eclipse。

我也不太明白,为什么要使用 D:\Dokumenty\Downloads\portaudio 中的 portaudio header 。当使用 MSYS 构建时,我使用了 ./configure --prefix=/mingw,库和包含文件存在于我的 MinGW 目录中。

提前感谢您的任何提示。

最佳答案

when I try to call any of the portaudio functions (Pa_Initialize), I get [link errors]

好的,一般的链接错误只是缺少库。

undefined reference to `__cxa_pure_virtual'

...可以通过添加 C++ 标准库来修复,可能是 -lstdc++

和 对 `waveOutGetNumDevs@0' 的 undefined reference

... 可以通过添加 libwinmm.a 或类似内容来修复。

why portaudio headers from D:\Dokumenty\Downloads\portaudio are being used

这些代表编译到 libportaudio 中的源代码。当它被构建时,它包含像 D:\Dokumenty\Downloads\portaudio/src/hostapi/wmme/pa_win_wmme.c 这样的源文件,它引用了像 waveOutWrite() 这样的函数>。现在您正在使用 libportaudio 生成可执行文件,您必须为链接器提供解析所有这些依赖项所需的库。

关于c - 使用 PortAudio 构建 C 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33625272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com