PortAudio 测试应用程序 - 未解析的外部符号 Pa_GetVersionInfo
PortAudio Test application - Unresolved External symbol Pa_GetVersionInfo
背景
我下载了 https://github.com/PortAudio/portaudio 并编译了一个 DLL(删除了 ASIO 支持)。
我是 运行 windows 10...Visual Studio 2019。使用 msvc 文件夹中的文件,我创建了一个 64 位 dll。在 build/msvc/ 文件夹下它创建了一个新的 x64/release 子文件夹,我看到以下文件:
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio/build/msvc/x64/Release$ ls -lah
total 3.8M
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 .
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 ..
-rwxrwxrwx 1 cp cp 13K Oct 6 14:56 pa_allocation.obj
-rwxrwxrwx 1 cp cp 118K Oct 6 14:56 pa_converters.obj
-rwxrwxrwx 1 cp cp 5.3K Oct 6 14:56 pa_cpuload.obj
-rwxrwxrwx 1 cp cp 5.3K Oct 6 14:56 pa_debugprint.obj
-rwxrwxrwx 1 cp cp 3.0K Oct 6 14:56 pa_dither.obj
-rwxrwxrwx 1 cp cp 66K Oct 6 14:56 pa_front.obj
-rwxrwxrwx 1 cp cp 21K Oct 6 14:56 pa_hostapi_skeleton.obj
-rwxrwxrwx 1 cp cp 60K Oct 6 14:56 pa_process.obj
-rwxrwxrwx 1 cp cp 14K Oct 6 14:56 pa_ringbuffer.obj
-rwxrwxrwx 1 cp cp 7.1K Oct 6 14:56 pa_stream.obj
-rwxrwxrwx 1 cp cp 2.0K Oct 6 14:56 pa_trace.obj
-rwxrwxrwx 1 cp cp 17K Oct 6 14:56 pa_win_coinitialize.obj
-rwxrwxrwx 1 cp cp 190K Oct 6 14:56 pa_win_ds.obj
-rwxrwxrwx 1 cp cp 25K Oct 6 14:56 pa_win_ds_dynlink.obj
-rwxrwxrwx 1 cp cp 1.5K Oct 6 14:56 pa_win_hostapis.obj
-rwxrwxrwx 1 cp cp 18K Oct 6 14:56 pa_win_util.obj
-rwxrwxrwx 1 cp cp 664K Oct 6 14:56 pa_win_wasapi.obj
-rwxrwxrwx 1 cp cp 19K Oct 6 14:56 pa_win_waveformat.obj
-rwxrwxrwx 1 cp cp 344K Oct 6 14:56 pa_win_wdmks.obj
-rwxrwxrwx 1 cp cp 29K Oct 6 14:56 pa_win_wdmks_utils.obj
-rwxrwxrwx 1 cp cp 154K Oct 6 14:56 pa_win_wmme.obj
-rwxrwxrwx 1 cp cp 1.3K Oct 6 14:56 pa_x86_plain_converters.obj
-rwxrwxrwx 1 cp cp 0 Oct 6 14:56 portaudio.Build.CppClean.log
-rwxrwxrwx 1 cp cp 287 Oct 6 14:56 portaudio.dll.recipe
-rwxrwxrwx 1 cp cp 3.4K Oct 6 14:56 portaudio.log
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 portaudio.tlog
-rwxrwxrwx 1 cp cp 0 Oct 6 14:56 portaudio.vcxproj.FileListAbsolute.txt
-rwxrwxrwx 1 cp cp 214K Oct 6 14:56 portaudio_x64.dll
-rwxrwxrwx 1 cp cp 7.4K Oct 6 14:56 portaudio_x64.exp
-rwxrwxrwx 1 cp cp 13K Oct 6 14:56 portaudio_x64.lib
-rwxrwxrwx 1 cp cp 1.5M Oct 6 14:56 portaudio_x64.pdb
-rwxrwxrwx 1 cp cp 268K Oct 6 14:56 vc142.pdb
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio/build/msvc/x64/Release$
酷。到目前为止一切顺利。
接下来,我创建一个控制台应用程序来尝试测试 DLL。具体来说,我:
具体来说,我想做这样的事情:
https://github.com/PortAudio/portaudio/blob/master/examples/pa_devs.c
我开始执行以下操作:
a) 创建一个名为“portaudio-listdevices-command”的 windows 控制台应用程序。它创建了一个“hello world”解决方案。它编译和运行没问题。
b) 我劫持了默认的“ConsoleApplication1.cpp”文件并试图将所有逻辑从 pa_devs.c 复制到这个 cpp 文件中。 cpp 文件中的代码如下所示:
c) 我将 portaudio 解决方案中的所有头文件直接复制到我的客户端应用程序文件夹中。
如果有帮助,这是客户端应用程序的文件夹结构:
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio-listdevices-command/ConsoleApplication1$ ls -lah
total 156K
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:16 .
drwxrwxrwx 1 cp cp 4.0K Oct 6 15:34 ..
drwxrwxrwx 1 cp cp 4.0K Oct 6 15:34 .vs
-rwxrwxrwx 1 cp cp 8.1K Oct 6 17:00 ConsoleApplication1.cpp
-rwxrwxrwx 1 cp cp 1.5K Oct 6 15:34 ConsoleApplication1.sln
-rwxrwxrwx 1 cp cp 7.9K Oct 7 08:29 ConsoleApplication1.vcxproj
-rwxrwxrwx 1 cp cp 992 Oct 6 15:34 ConsoleApplication1.vcxproj.filters
-rwxrwxrwx 1 cp cp 168 Oct 6 15:34 ConsoleApplication1.vcxproj.user
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:05 Debug
-rwxrwxrwx 1 cp cp 5.8K Oct 6 13:24 pa_asio.h
-rwxrwxrwx 1 cp cp 2.9K Oct 6 13:24 pa_jack.h
-rwxrwxrwx 1 cp cp 3.9K Oct 6 13:24 pa_linux_alsa.h
-rwxrwxrwx 1 cp cp 7.6K Oct 6 13:24 pa_mac_core.h
-rwxrwxrwx 1 cp cp 3.5K Oct 6 13:24 pa_win_ds.h
-rwxrwxrwx 1 cp cp 24K Oct 6 13:24 pa_win_wasapi.h
-rwxrwxrwx 1 cp cp 8.9K Oct 6 13:24 pa_win_waveformat.h
-rwxrwxrwx 1 cp cp 5.0K Oct 6 13:24 pa_win_wdmks.h
-rwxrwxrwx 1 cp cp 6.9K Oct 6 13:24 pa_win_wmme.h
-rwxrwxrwx 1 cp cp 48K Oct 6 13:24 portaudio.h
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:16 x64
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio-listdevices-command/ConsoleApplication1$
问题
当我尝试编译客户端应用程序时,这是我遇到的错误:
Error LNK2019 unresolved external symbol Pa_GetVersionInfo referenced in function main ConsoleApplication1 C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\ConsoleApplication1.obj 1
到目前为止我已经尝试过:
我在我的项目中修改了以下属性:
Project --> Properties --> Linker --> Input --> Additional Dependencies --> "portaudio_x64.lib"
Project --> Properties --> VC++ Directories --> Library Directories --> c:\Users\cp\source\github\portaudio\build\msvc\x64\Release
头文件刚刚从 portaudio 源文件夹直接复制到客户端应用程序,所以现在我有这个:
对于它的价值,在我的 ConsoleApplication1.cpp 文件中,当我将鼠标悬停在对 Pa_GetVersion() 的调用上时,它确实为我提供了上下文帮助并向我展示了该函数的作用。这是否证明 lib 文件正在运行?
如有任何帮助,我们将不胜感激。
**DUMPBIN 结果 **
PS C:\Users\cp\source\github\portaudio\build\msvc\x64\Release> dumpbin /exports portaudio_x64.dll
Microsoft (R) COFF/PE Dumper Version 14.27.29111.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file portaudio_x64.dll
File Type: DLL
Section contains the following exports for portaudio_x64.dll
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
68 number of functions
48 number of names
ordinal hint RVA name
52 0 0001CE10 PaUtil_InitializeX86PlainConverters = PaUtil_InitializeX86PlainConverters
55 1 00003110 PaUtil_SetDebugPrintFunction = PaUtil_SetDebugPrintFunction
56 2 0000D100 PaWasapi_GetAudioClient = PaWasapi_GetAudioClient
58 3 0000D140 PaWasapi_GetDeviceCurrentFormat = PaWasapi_GetDeviceCurrentFormat
59 4 0000D1A0 PaWasapi_GetDeviceDefaultFormat = PaWasapi_GetDeviceDefaultFormat
60 5 0000D270 PaWasapi_GetDeviceMixFormat = PaWasapi_GetDeviceMixFormat
61 6 0000D340 PaWasapi_GetDeviceRole = PaWasapi_GetDeviceRole
64 7 0000D3C0 PaWasapi_GetFramesPerHostBuffer = PaWasapi_GetFramesPerHostBuffer
65 8 0000D3F0 PaWasapi_GetJackCount = PaWasapi_GetJackCount
66 9 0000D5D0 PaWasapi_GetJackDescription = PaWasapi_GetJackDescription
67 A 0000DAA0 PaWasapi_SetDefaultInterfaceId = PaWasapi_SetDefaultInterfaceId
68 B 0000DAB0 PaWasapi_SetStreamStateHandler = PaWasapi_SetStreamStateHandler
62 C 0000DAD0 PaWasapi_ThreadPriorityBoost = PaWasapi_ThreadPriorityBoost
63 D 0000DB10 PaWasapi_ThreadPriorityRevert = PaWasapi_ThreadPriorityRevert
23 E 00003520 Pa_AbortStream = Pa_AbortStream
19 F 00003570 Pa_CloseStream = Pa_CloseStream
7 10 000035D0 Pa_GetDefaultHostApi = Pa_GetDefaultHostApi
13 11 00003600 Pa_GetDefaultInputDevice = Pa_GetDefaultInputDevice
14 12 00003630 Pa_GetDefaultOutputDevice = Pa_GetDefaultOutputDevice
12 13 00003660 Pa_GetDeviceCount = Pa_GetDeviceCount
15 14 00003680 Pa_GetDeviceInfo = Pa_GetDeviceInfo
3 15 000036C0 Pa_GetErrorText = Pa_GetErrorText
6 16 00003870 Pa_GetHostApiCount = Pa_GetHostApiCount
8 17 00003890 Pa_GetHostApiInfo = Pa_GetHostApiInfo
11 18 000038C0 Pa_GetLastHostErrorInfo = Pa_GetLastHostErrorInfo
33 19 000038D0 Pa_GetSampleSize = Pa_GetSampleSize
28 1A 00003950 Pa_GetStreamCpuLoad = Pa_GetStreamCpuLoad
26 1B 00003980 Pa_GetStreamInfo = Pa_GetStreamInfo
31 1C 000039B0 Pa_GetStreamReadAvailable = Pa_GetStreamReadAvailable
27 1D 000039E0 Pa_GetStreamTime = Pa_GetStreamTime
32 1E 00003A10 Pa_GetStreamWriteAvailable = Pa_GetStreamWriteAvailable
1 1F 00003A40 Pa_GetVersion = Pa_GetVersion
2 20 00003A60 Pa_GetVersionText = Pa_GetVersionText
10 21 00003A70 Pa_HostApiDeviceIndexToDeviceIndex = Pa_HostApiDeviceIndexToDeviceIndex
9 22 00003AC0 Pa_HostApiTypeIdToHostApiIndex = Pa_HostApiTypeIdToHostApiIndex
4 23 00003B10 Pa_Initialize = Pa_Initialize
16 24 00003B50 Pa_IsFormatSupported = Pa_IsFormatSupported
25 25 00003C80 Pa_IsStreamActive = Pa_IsStreamActive
24 26 00003CB0 Pa_IsStreamStopped = Pa_IsStreamStopped
18 27 00003CE0 Pa_OpenDefaultStream = Pa_OpenDefaultStream
17 28 00003DF0 Pa_OpenStream = Pa_OpenStream
29 29 00003FB0 Pa_ReadStream = Pa_ReadStream
20 2A 00004050 Pa_SetStreamFinishedCallback = Pa_SetStreamFinishedCallback
34 2B 0001C700 Pa_Sleep = Pa_Sleep
21 2C 000040A0 Pa_StartStream = Pa_StartStream
22 2D 000040F0 Pa_StopStream = Pa_StopStream
5 2E 00004140 Pa_Terminate = Pa_Terminate
30 2F 00004180 Pa_WriteStream = Pa_WriteStream
Summary
3000 .data
7000 .pdata
24000 .rdata
1000 .reloc
1000 .rsrc
6B000 .text
1000 _RDATA
来自 Link.exe
的详细输出
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> Tracking command:
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Current\Bin\Tracker.exe /a /d "C:\Program Files (x86)\MSBuild.0\FileTracker\FileTracker32.dll" /i C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleA.8f735e32.tlog /r C:\USERS\cp\SOURCE\GITHUB\PORTAUDIO-LISTDEVICES-COMMAND\CONSOLEAPPLICATION1\X64\DEBUG\CONSOLEAPPLICATION1.OBJ /b MSBuildConsole_CancelEventca601256d110470b96dcd6bd48d0231f /c "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe" /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
现在定义了额外的库路径
最新 Link 错误
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> Tracking command:
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Current\Bin\Tracker.exe /a /d "C:\Program Files (x86)\MSBuild.0\FileTracker\FileTracker32.dll" /i C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleA.8f735e32.tlog /r C:\USERS\cp\SOURCE\GITHUB\PORTAUDIO-LISTDEVICES-COMMAND\CONSOLEAPPLICATION1\X64\DEBUG\CONSOLEAPPLICATION1.OBJ /b MSBuildConsole_CancelEventa9f191895925491f926a123cade0b276 /c "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe" /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> ConsoleApplication1.obj : error LNK2019: unresolved external symbol Pa_GetVersionInfo referenced in function main
1> C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals
1> The command exited with code 1120.
1> Done executing task "Link" -- FAILED.
1>Done building target "Link" in project "ConsoleApplication1.vcxproj" -- FAILED.
1>
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol Pa_GetVersionInfo referenced in function main
1>C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals
1> 0 Warning(s)
1> 2 Error(s)
所以我不能以此为荣。我只是发布答案,所以我们可以关闭这个问题。
但问题出在 portaudio 库本身
portinfo.def 文件未导出我尝试调用的方法 - 示例文件中引用的方法。
修复方法是将以下行添加到 portinfo.def 文件:
Pa_GetVersionInfo@69
现在我的客户端/控制台应用程序可以编译了。
我将在今天晚些时候向 portaudio repo 提交一个补丁,供社区考虑。但感谢@HansPassant 和 πìντα ῥεῖ
背景
我下载了 https://github.com/PortAudio/portaudio 并编译了一个 DLL(删除了 ASIO 支持)。 我是 运行 windows 10...Visual Studio 2019。使用 msvc 文件夹中的文件,我创建了一个 64 位 dll。在 build/msvc/ 文件夹下它创建了一个新的 x64/release 子文件夹,我看到以下文件:
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio/build/msvc/x64/Release$ ls -lah
total 3.8M
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 .
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 ..
-rwxrwxrwx 1 cp cp 13K Oct 6 14:56 pa_allocation.obj
-rwxrwxrwx 1 cp cp 118K Oct 6 14:56 pa_converters.obj
-rwxrwxrwx 1 cp cp 5.3K Oct 6 14:56 pa_cpuload.obj
-rwxrwxrwx 1 cp cp 5.3K Oct 6 14:56 pa_debugprint.obj
-rwxrwxrwx 1 cp cp 3.0K Oct 6 14:56 pa_dither.obj
-rwxrwxrwx 1 cp cp 66K Oct 6 14:56 pa_front.obj
-rwxrwxrwx 1 cp cp 21K Oct 6 14:56 pa_hostapi_skeleton.obj
-rwxrwxrwx 1 cp cp 60K Oct 6 14:56 pa_process.obj
-rwxrwxrwx 1 cp cp 14K Oct 6 14:56 pa_ringbuffer.obj
-rwxrwxrwx 1 cp cp 7.1K Oct 6 14:56 pa_stream.obj
-rwxrwxrwx 1 cp cp 2.0K Oct 6 14:56 pa_trace.obj
-rwxrwxrwx 1 cp cp 17K Oct 6 14:56 pa_win_coinitialize.obj
-rwxrwxrwx 1 cp cp 190K Oct 6 14:56 pa_win_ds.obj
-rwxrwxrwx 1 cp cp 25K Oct 6 14:56 pa_win_ds_dynlink.obj
-rwxrwxrwx 1 cp cp 1.5K Oct 6 14:56 pa_win_hostapis.obj
-rwxrwxrwx 1 cp cp 18K Oct 6 14:56 pa_win_util.obj
-rwxrwxrwx 1 cp cp 664K Oct 6 14:56 pa_win_wasapi.obj
-rwxrwxrwx 1 cp cp 19K Oct 6 14:56 pa_win_waveformat.obj
-rwxrwxrwx 1 cp cp 344K Oct 6 14:56 pa_win_wdmks.obj
-rwxrwxrwx 1 cp cp 29K Oct 6 14:56 pa_win_wdmks_utils.obj
-rwxrwxrwx 1 cp cp 154K Oct 6 14:56 pa_win_wmme.obj
-rwxrwxrwx 1 cp cp 1.3K Oct 6 14:56 pa_x86_plain_converters.obj
-rwxrwxrwx 1 cp cp 0 Oct 6 14:56 portaudio.Build.CppClean.log
-rwxrwxrwx 1 cp cp 287 Oct 6 14:56 portaudio.dll.recipe
-rwxrwxrwx 1 cp cp 3.4K Oct 6 14:56 portaudio.log
drwxrwxrwx 1 cp cp 4.0K Oct 6 14:56 portaudio.tlog
-rwxrwxrwx 1 cp cp 0 Oct 6 14:56 portaudio.vcxproj.FileListAbsolute.txt
-rwxrwxrwx 1 cp cp 214K Oct 6 14:56 portaudio_x64.dll
-rwxrwxrwx 1 cp cp 7.4K Oct 6 14:56 portaudio_x64.exp
-rwxrwxrwx 1 cp cp 13K Oct 6 14:56 portaudio_x64.lib
-rwxrwxrwx 1 cp cp 1.5M Oct 6 14:56 portaudio_x64.pdb
-rwxrwxrwx 1 cp cp 268K Oct 6 14:56 vc142.pdb
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio/build/msvc/x64/Release$
酷。到目前为止一切顺利。
接下来,我创建一个控制台应用程序来尝试测试 DLL。具体来说,我:
具体来说,我想做这样的事情: https://github.com/PortAudio/portaudio/blob/master/examples/pa_devs.c
我开始执行以下操作: a) 创建一个名为“portaudio-listdevices-command”的 windows 控制台应用程序。它创建了一个“hello world”解决方案。它编译和运行没问题。 b) 我劫持了默认的“ConsoleApplication1.cpp”文件并试图将所有逻辑从 pa_devs.c 复制到这个 cpp 文件中。 cpp 文件中的代码如下所示:
c) 我将 portaudio 解决方案中的所有头文件直接复制到我的客户端应用程序文件夹中。
如果有帮助,这是客户端应用程序的文件夹结构:
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio-listdevices-command/ConsoleApplication1$ ls -lah
total 156K
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:16 .
drwxrwxrwx 1 cp cp 4.0K Oct 6 15:34 ..
drwxrwxrwx 1 cp cp 4.0K Oct 6 15:34 .vs
-rwxrwxrwx 1 cp cp 8.1K Oct 6 17:00 ConsoleApplication1.cpp
-rwxrwxrwx 1 cp cp 1.5K Oct 6 15:34 ConsoleApplication1.sln
-rwxrwxrwx 1 cp cp 7.9K Oct 7 08:29 ConsoleApplication1.vcxproj
-rwxrwxrwx 1 cp cp 992 Oct 6 15:34 ConsoleApplication1.vcxproj.filters
-rwxrwxrwx 1 cp cp 168 Oct 6 15:34 ConsoleApplication1.vcxproj.user
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:05 Debug
-rwxrwxrwx 1 cp cp 5.8K Oct 6 13:24 pa_asio.h
-rwxrwxrwx 1 cp cp 2.9K Oct 6 13:24 pa_jack.h
-rwxrwxrwx 1 cp cp 3.9K Oct 6 13:24 pa_linux_alsa.h
-rwxrwxrwx 1 cp cp 7.6K Oct 6 13:24 pa_mac_core.h
-rwxrwxrwx 1 cp cp 3.5K Oct 6 13:24 pa_win_ds.h
-rwxrwxrwx 1 cp cp 24K Oct 6 13:24 pa_win_wasapi.h
-rwxrwxrwx 1 cp cp 8.9K Oct 6 13:24 pa_win_waveformat.h
-rwxrwxrwx 1 cp cp 5.0K Oct 6 13:24 pa_win_wdmks.h
-rwxrwxrwx 1 cp cp 6.9K Oct 6 13:24 pa_win_wmme.h
-rwxrwxrwx 1 cp cp 48K Oct 6 13:24 portaudio.h
drwxrwxrwx 1 cp cp 4.0K Oct 7 08:16 x64
cp@DESKTOP-ESLJ8N0:/mnt/c/Users/cp/source/github/portaudio-listdevices-command/ConsoleApplication1$
问题
当我尝试编译客户端应用程序时,这是我遇到的错误:
Error LNK2019 unresolved external symbol Pa_GetVersionInfo referenced in function main ConsoleApplication1 C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\ConsoleApplication1.obj 1
到目前为止我已经尝试过:
我在我的项目中修改了以下属性:
Project --> Properties --> Linker --> Input --> Additional Dependencies --> "portaudio_x64.lib"
Project --> Properties --> VC++ Directories --> Library Directories --> c:\Users\cp\source\github\portaudio\build\msvc\x64\Release
头文件刚刚从 portaudio 源文件夹直接复制到客户端应用程序,所以现在我有这个:
对于它的价值,在我的 ConsoleApplication1.cpp 文件中,当我将鼠标悬停在对 Pa_GetVersion() 的调用上时,它确实为我提供了上下文帮助并向我展示了该函数的作用。这是否证明 lib 文件正在运行?
如有任何帮助,我们将不胜感激。
**DUMPBIN 结果 **
PS C:\Users\cp\source\github\portaudio\build\msvc\x64\Release> dumpbin /exports portaudio_x64.dll
Microsoft (R) COFF/PE Dumper Version 14.27.29111.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file portaudio_x64.dll
File Type: DLL
Section contains the following exports for portaudio_x64.dll
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
68 number of functions
48 number of names
ordinal hint RVA name
52 0 0001CE10 PaUtil_InitializeX86PlainConverters = PaUtil_InitializeX86PlainConverters
55 1 00003110 PaUtil_SetDebugPrintFunction = PaUtil_SetDebugPrintFunction
56 2 0000D100 PaWasapi_GetAudioClient = PaWasapi_GetAudioClient
58 3 0000D140 PaWasapi_GetDeviceCurrentFormat = PaWasapi_GetDeviceCurrentFormat
59 4 0000D1A0 PaWasapi_GetDeviceDefaultFormat = PaWasapi_GetDeviceDefaultFormat
60 5 0000D270 PaWasapi_GetDeviceMixFormat = PaWasapi_GetDeviceMixFormat
61 6 0000D340 PaWasapi_GetDeviceRole = PaWasapi_GetDeviceRole
64 7 0000D3C0 PaWasapi_GetFramesPerHostBuffer = PaWasapi_GetFramesPerHostBuffer
65 8 0000D3F0 PaWasapi_GetJackCount = PaWasapi_GetJackCount
66 9 0000D5D0 PaWasapi_GetJackDescription = PaWasapi_GetJackDescription
67 A 0000DAA0 PaWasapi_SetDefaultInterfaceId = PaWasapi_SetDefaultInterfaceId
68 B 0000DAB0 PaWasapi_SetStreamStateHandler = PaWasapi_SetStreamStateHandler
62 C 0000DAD0 PaWasapi_ThreadPriorityBoost = PaWasapi_ThreadPriorityBoost
63 D 0000DB10 PaWasapi_ThreadPriorityRevert = PaWasapi_ThreadPriorityRevert
23 E 00003520 Pa_AbortStream = Pa_AbortStream
19 F 00003570 Pa_CloseStream = Pa_CloseStream
7 10 000035D0 Pa_GetDefaultHostApi = Pa_GetDefaultHostApi
13 11 00003600 Pa_GetDefaultInputDevice = Pa_GetDefaultInputDevice
14 12 00003630 Pa_GetDefaultOutputDevice = Pa_GetDefaultOutputDevice
12 13 00003660 Pa_GetDeviceCount = Pa_GetDeviceCount
15 14 00003680 Pa_GetDeviceInfo = Pa_GetDeviceInfo
3 15 000036C0 Pa_GetErrorText = Pa_GetErrorText
6 16 00003870 Pa_GetHostApiCount = Pa_GetHostApiCount
8 17 00003890 Pa_GetHostApiInfo = Pa_GetHostApiInfo
11 18 000038C0 Pa_GetLastHostErrorInfo = Pa_GetLastHostErrorInfo
33 19 000038D0 Pa_GetSampleSize = Pa_GetSampleSize
28 1A 00003950 Pa_GetStreamCpuLoad = Pa_GetStreamCpuLoad
26 1B 00003980 Pa_GetStreamInfo = Pa_GetStreamInfo
31 1C 000039B0 Pa_GetStreamReadAvailable = Pa_GetStreamReadAvailable
27 1D 000039E0 Pa_GetStreamTime = Pa_GetStreamTime
32 1E 00003A10 Pa_GetStreamWriteAvailable = Pa_GetStreamWriteAvailable
1 1F 00003A40 Pa_GetVersion = Pa_GetVersion
2 20 00003A60 Pa_GetVersionText = Pa_GetVersionText
10 21 00003A70 Pa_HostApiDeviceIndexToDeviceIndex = Pa_HostApiDeviceIndexToDeviceIndex
9 22 00003AC0 Pa_HostApiTypeIdToHostApiIndex = Pa_HostApiTypeIdToHostApiIndex
4 23 00003B10 Pa_Initialize = Pa_Initialize
16 24 00003B50 Pa_IsFormatSupported = Pa_IsFormatSupported
25 25 00003C80 Pa_IsStreamActive = Pa_IsStreamActive
24 26 00003CB0 Pa_IsStreamStopped = Pa_IsStreamStopped
18 27 00003CE0 Pa_OpenDefaultStream = Pa_OpenDefaultStream
17 28 00003DF0 Pa_OpenStream = Pa_OpenStream
29 29 00003FB0 Pa_ReadStream = Pa_ReadStream
20 2A 00004050 Pa_SetStreamFinishedCallback = Pa_SetStreamFinishedCallback
34 2B 0001C700 Pa_Sleep = Pa_Sleep
21 2C 000040A0 Pa_StartStream = Pa_StartStream
22 2D 000040F0 Pa_StopStream = Pa_StopStream
5 2E 00004140 Pa_Terminate = Pa_Terminate
30 2F 00004180 Pa_WriteStream = Pa_WriteStream
Summary
3000 .data
7000 .pdata
24000 .rdata
1000 .reloc
1000 .rsrc
6B000 .text
1000 _RDATA
来自 Link.exe
的详细输出1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> Tracking command:
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Current\Bin\Tracker.exe /a /d "C:\Program Files (x86)\MSBuild.0\FileTracker\FileTracker32.dll" /i C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleA.8f735e32.tlog /r C:\USERS\cp\SOURCE\GITHUB\PORTAUDIO-LISTDEVICES-COMMAND\CONSOLEAPPLICATION1\X64\DEBUG\CONSOLEAPPLICATION1.OBJ /b MSBuildConsole_CancelEventca601256d110470b96dcd6bd48d0231f /c "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe" /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
现在定义了额外的库路径
最新 Link 错误
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> Tracking command:
1> C:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Current\Bin\Tracker.exe /a /d "C:\Program Files (x86)\MSBuild.0\FileTracker\FileTracker32.dll" /i C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleA.8f735e32.tlog /r C:\USERS\cp\SOURCE\GITHUB\PORTAUDIO-LISTDEVICES-COMMAND\CONSOLEAPPLICATION1\X64\DEBUG\CONSOLEAPPLICATION1.OBJ /b MSBuildConsole_CancelEventa9f191895925491f926a123cade0b276 /c "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Tools\MSVC.27.29110\bin\HostX86\x64\link.exe" /ERRORREPORT:PROMPT /OUT:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release /LIBPATH:C:\Users\cp\source\github\portaudio\build\msvc\x64\Release portaudio_x64.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 x64\Debug\ConsoleApplication1.obj
1> ConsoleApplication1.obj : error LNK2019: unresolved external symbol Pa_GetVersionInfo referenced in function main
1> C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals
1> The command exited with code 1120.
1> Done executing task "Link" -- FAILED.
1>Done building target "Link" in project "ConsoleApplication1.vcxproj" -- FAILED.
1>
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>ConsoleApplication1.obj : error LNK2019: unresolved external symbol Pa_GetVersionInfo referenced in function main
1>C:\Users\cp\source\github\portaudio-listdevices-command\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals
1> 0 Warning(s)
1> 2 Error(s)
所以我不能以此为荣。我只是发布答案,所以我们可以关闭这个问题。 但问题出在 portaudio 库本身 portinfo.def 文件未导出我尝试调用的方法 - 示例文件中引用的方法。
修复方法是将以下行添加到 portinfo.def 文件:
Pa_GetVersionInfo@69
现在我的客户端/控制台应用程序可以编译了。 我将在今天晚些时候向 portaudio repo 提交一个补丁,供社区考虑。但感谢@HansPassant 和 πìντα ῥεῖ