Problem with mex compilation of Portaudio

7 views (last 30 days)
Dorian
Dorian on 30 Jan 2015
Edited: Walter Roberson on 30 Jul 2015
Hi
I am trying to install the Playrec matlab software http://www.playrec.co.uk/compiling.html, which needs to compile the portaudio http://www.portaudio.com/download.html and ASIO SDK2.3 http://www.steinberg.net/en/company/developers.html libraries.
The code provided by the author of Playrec uses the function
failed = mex(build_args{:});
where build_args{:} =
>> build_args {:}
ans =
-g
ans =
-v
ans =
-output
ans =
playrec
ans =
-DWIN32
ans =
-DPA_USE_ASIO
ans =
-DDEBUG
ans =
-largeArrayDims
ans =
-IC:\Users\Asus\Desktop\PlayRec\lib\portaudio\src\hostapi\asio\ASIOSDK\common
ans =
-IC:\Users\Asus\Desktop\playrec\m_files\..\src
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\common
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\alsa
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asihpi
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\coreaudio
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\dsound
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\jack
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\oss
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\wasapi
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\wdmks
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\wmme
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\mac_osx
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\unix
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\win
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\include
ans =
-IC:\Users\Asus\Desktop\Microsoft_SDK\include
ans =
-IC:\Users\Asus\Desktop\Microsoft_SDK\lib
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\common
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\host
ans =
-IC:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\host\pc
ans =
-LC:\Users\Asus\Desktop\Microsoft_SDK\lib
ans =
-luser32
ans =
-lole32
ans =
-ladvapi32
ans =
-lwinmm
ans =
C:\Users\Asus\Desktop\playrec\m_files\..\src\mex_dll_core.c
ans =
C:\Users\Asus\Desktop\playrec\m_files\..\src\pa_dll_playrec.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_allocation.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_converters.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_cpuload.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_debugprint.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_dither.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_front.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_process.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\skeleton\pa_hostapi_skeleton.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_stream.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_trace.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\pa_asio.cpp
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\win\pa_win_hostapis.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\win\pa_win_util.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\win\pa_win_waveformat.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\os\win\pa_x86_plain_converters.c
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\common\asio.cpp
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\host\asiodrivers.cpp
ans =
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\hostapi\asio\ASIOSDK\host\pc\asiolist.cpp
%%%%%%%%%%%%%%%%%
From this function I get the following error message, and I do not understand how to fix it :
Contents of C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\mex_tmp.rsp:
user32.lib ole32.lib advapi32.lib winmm.lib C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\mex_dll_core.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_dll_playrec.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_allocation.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_converters.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_cpuload.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_debugprint.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_dither.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_front.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_process.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_hostapi_skeleton.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_stream.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_trace.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_asio.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_win_hostapis.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_win_util.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_win_waveformat.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\pa_x86_plain_converters.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\asio.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\asiodrivers.obj C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\asiolist.obj
--> link /out:"playrec.mexw32" /debug /PDB:"playrec.mexw32.pdb" /dll /export:mexFunction /LIBPATH:"C:\Users\Asus\Desktop\R2014a\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\templib.x" /MAP:"playrec.mexw32.map" @C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\mex_tmp.rsp
Création de la bibliothèque C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\templib.x et de l'objet C:\Users\Asus\AppData\Local\Temp\mex_tj7Daf\templib.exp
pa_asio.obj : error LNK2019: symbole externe non résolu _PaWinUtil_CoUninitialize référencé dans la fonction __catch$_PaAsio_Initialize$3
pa_asio.obj : error LNK2019: symbole externe non résolu _PaWinUtil_CoInitialize référencé dans la fonction _PaAsio_Initialize
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_InitializeRingBuffer référencé dans la fonction "int __cdecl OpenStream(struct PaUtilHostApiRepresentation *,void * *,struct PaStreamParameters const *,struct PaStreamParameters const *,double,unsigned long,unsigned long,int (__cdecl*)(void const *,void *,unsigned long,struct PaStreamCallbackTimeInfo const *,unsigned long,void *),void *)" (?OpenStream@@YAHPAUPaUtilHostApiRepresentation@@PAPAXPBUPaStreamParameters@@2NKKP6AHPBXPAXKPBUPaStreamCallbackTimeInfo@@K4@Z4@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_AdvanceRingBufferWriteIndex référencé dans la fonction "int __cdecl StartStream(void *)" (?StartStream@@YAHPAX@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_FlushRingBuffer référencé dans la fonction "int __cdecl StartStream(void *)" (?StartStream@@YAHPAX@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_AdvanceRingBufferReadIndex référencé dans la fonction "int __cdecl ReadStream(void *,void *,unsigned long)" (?ReadStream@@YAHPAX0K@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_GetRingBufferReadRegions référencé dans la fonction "int __cdecl ReadStream(void *,void *,unsigned long)" (?ReadStream@@YAHPAX0K@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_GetRingBufferReadAvailable référencé dans la fonction "int __cdecl ReadStream(void *,void *,unsigned long)" (?ReadStream@@YAHPAX0K@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_GetRingBufferWriteRegions référencé dans la fonction "int __cdecl WriteStream(void *,void const *,unsigned long)" (?WriteStream@@YAHPAXPBXK@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_GetRingBufferWriteAvailable référencé dans la fonction "int __cdecl WriteStream(void *,void const *,unsigned long)" (?WriteStream@@YAHPAXPBXK@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_WriteRingBuffer référencé dans la fonction "int __cdecl BlockingIoPaCallback(void const *,void *,unsigned long,struct PaStreamCallbackTimeInfo const *,unsigned long,void *)" (?BlockingIoPaCallback@@YAHPBXPAXKPBUPaStreamCallbackTimeInfo@@K1@Z)
pa_asio.obj : error LNK2019: symbole externe non résolu _PaUtil_ReadRingBuffer référencé dans la fonction "int __cdecl BlockingIoPaCallback(void const *,void *,unsigned long,struct PaStreamCallbackTimeInfo const *,unsigned long,void *)" (?BlockingIoPaCallback@@YAHPBXPAXKPBUPaStreamCallbackTimeInfo@@K1@Z)
playrec.mexw32 : fatal error LNK1120: 12 externes non résolus
C:\USERS\ASUS\DESKTOP\R2014A\BIN\MEX.PL: Error: Link of 'playrec.mexw32' failed.
Thanks. Dorian
  1 Comment
Roman  Katzer
Roman Katzer on 4 Jun 2015
Hi Dorian,
I had the exact same error. As Geoff says, the problem is that that the compiled pa_ringbuffer.c is not found by the linker. I found out that for whatever reason, compile_playrec_func.m does not set up the pa_common_files variable for Windows. So I added it. Starting at line 115 in compile_playrec_func.m, it now looks like this:
elseif is_os('WIN')
compiler_flags = [compiler_flags, {'WIN32'}];
link_libs = [link_libs, {'user32.lib', 'ole32.lib', ...
'advapi32.lib', 'winmm.lib'}];
pa_os_specific_files = [pa_os_specific_files, ...
{'src/os/win/pa_win_hostapis.c',...
'src/os/win/pa_win_util.c',...
'src/os/win/pa_win_waveformat.c',...
'src/os/win/pa_x86_plain_converters.c'}];
% add necessary c files to pa_common_files
pa_common_files = [pa_common_files, ...
{'src/common/pa_ringbuffer.c', ...
'src/os/win/pa_win_coinitialize.c'}];
if ~isempty(sdk_path)
api_include_dirs = [api_include_dirs,...
[...]
As you can see, it turns out that pa_win_coinitialize.c is also needed.
HTH, Roman

Sign in to comment.

Answers (2)

Geoff Hayes
Geoff Hayes on 2 Feb 2015
Dorian - according to the http://portaudio.com/docs/v19-doxydocs-dev/pa__ringbuffer_8c.html link, these unresolved links are to functions defined in the pa_ringbuffer.c file. Try adding it to your build arguments list as
C:\Users\Asus\Desktop\playrec\lib\portaudio\src\common\pa_ringbuffer.c
only if the above path is valid (i.e. does this file exist at this location?). If you do have this file, then it will need to be compiled and linked into the build script.

Roman  Katzer
Roman Katzer on 30 Jul 2015
I have now been trying to compile playrec on Windows 7 x64. Maybe my pain can avoid someone else's.
Software versions:
  • Matlab 2013a
  • two playrec versions, with READMEs from 2014-03-31 (Trial 1-3) and 2015-06-20 (Trial 4-6)
  • portaudio pa_stable_v19_20140130
  • Microsoft Visual C++ 2008 + Microsoft SDK for Windows 7
  • Diect X: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)
  • ASIO: C:\Users\katzer\Matlab\ASIOSDK2.3
  • Portaudio: C:\Users\katzer\Matlab\portaudio
Compiling with ASIO, Dirext X and WASAPI support.
Trial 1: >> compile_playrec
Undefined function 'exist' for input arguments of type 'cell'.
Error in compile_playrec_func (line 162)
if exist(resolve_paths(dsound_path, {'lib/x64'}),'dir')
So I put a char() around the resolve_paths function.
Trial 2: (see trial2.txt)
So to get rid of unresolved dependencies I tried my fix form here that had worked before (see comment above at top of page)
% add necessary c files to pa_common_files
pa_common_files = [pa_common_files, ...
{'src/common/pa_ringbuffer.c', ...
'src/os/win/pa_win_coinitialize.c
Trial 3: (see trial3.txt)
Unfortunately, that didn't work either. I got additional warnings (line 211):
C:\Users\katzer\AppData\Local\Temp\mex_KgCVoQ\pa_ringbuffer.obj : warning LNK4042: object specified more than once; extras ignored
C:\Users\katzer\AppData\Local\Temp\mex_KgCVoQ\pa_win_coinitialize.obj : warning LNK4042: object specified more than once; extras ignored
Trial 4: So now I remembered I hadn't had all those difficulties before. The unresolved symbols errors had looked differently, too. I copied the old playrec directory over from a different machine and tried the whole thing again.
>> compile_playrec
build_mex: Unable to find 'C:\Users\katzer\Matlab\portaudio\src\hostapi\wasapi\pa_win_wasapi.cpp'
Sure enough, it's not a cpp file but a c file.
Trial 5: Just renaming the file got me more errors, though (note I'm not a C/C++ developer): (see trial5.txt)
Trial 6: Edit compile_playrec_func.m to look for a c file instead of cpp:
pa_api_specific_files = [pa_api_specific_files,...
{'src/hostapi/wasapi/pa_win_wasapi.c'}]; % ROMAN: was cpp
That finally did the trick - it gave me a playrec.mexw64

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!