閱讀848 返回首頁    go 阿裏雲 go 技術社區[雲棲]


DirectSound示例的配置

      最近開始研究音視頻處理,買了本垃圾書《VC++音頻/視頻處理技術及工程實踐》,那本書完全是照搬Direct X的幫助文檔,而且還抄襲了網友“智慧的魚“發表的博文《DirectSound開發指南》(名字可能有出入),而且還是東拚西揍,看得人雲裏霧裏,很不爽讓我傷透了心!

      於是我開始研究Direct X幫助文檔,還好英語過得去,都看的懂,上麵有很多具有實際參考價值的示例,於是開始研究。

用VC6.0打開,編譯,卻怎麼都不通過,提示”Cannot open include file: 'dxerr9.h': No such file or directory“

       很明顯,沒有找到該文件的路徑,我搜索了一下,在X:/Program Files/DirectX/Include路徑下(X代表Direct X安裝盤符),

於是在Tool-->Options-->Directories-->Include files下添加X:/Program Files/DirectX/Include files ,如上圖,編譯,結果出現如下錯誤:

 

Compiling...

playsound.cpp

../../common/include/DSUtil.h(50) : error C2146: syntax error : missing ';' before identifier 'm_pDS'

../../common/include/DSUtil.h(50) : error C2501: 'LPDIRECTSOUND8' : missing storage-class or type specifiers

../../common/include/DSUtil.h(50) : error C2501: 'm_pDS' : missing storage-class or type specifiers

../../common/include/DSUtil.h(57) : error C2146: syntax error : missing ';' before identifier 'GetDirectSound'

../../common/include/DSUtil.h(57) : error C2433: 'LPDIRECTSOUND8' : 'inline' not permitted on data declarations

../../common/include/DSUtil.h(57) : error C2501: 'LPDIRECTSOUND8' : missing storage-class or type specifiers

.................................

 

E:/Program Files/DirectX/Samples/C++/common/src/dsutil.cpp(438) : error C2039: 'guid3DAlgorithm' : is not a member of '_DSBUFFERDESC'

        E:/Program Files/Microsoft Visual Studio/VC98/INCLUDE/dsound.h(96) : see declaration of '_DSBUFFERDESC'

E:/Program Files/DirectX/Samples/C++/common/src/dsutil.cpp(441) : error C2227: left of '->CreateSoundBuffer' must point to class/struct/union

Error executing cl.exe.

 

playsound.exe - 32 error(s), 2 warning(s)

繼續研究發現有個路徑沒有包含進去X:/PROGRAM FILES/DIRECTX/SAMPLES/C++/COMMON/INCLUDE,於是繼續添加,編譯,還是出錯:內容同上。

 

 

 

後來在網上查找,發現要將插入的路徑條目提到最上麵去,提上去後,發現編譯通過,OK!

補充:後來發現不需要X:/PROGRAM FILES/DIRECTX/SAMPLES/C++/COMMON/INCLUDE

如圖:

但是鏈接出錯,錯誤如下:

 

Compiling...

playsound.cpp

dsutil.cpp

Linking...

LINK : fatal error LNK1104: cannot open file "dxerr9.lib"

Error executing link.exe.

 

playsound.exe - 1 error(s), 0 warning(s)

 

看來應該是沒有包含Lib庫的路徑,再次研究,發現要添加X:/PROGRAM FILES/DIRECTX/LIB
到Tool-->Options-->Directories-->Include files下添加X:/Program Files/DirectX/Librarys files下,好,添加,結果連接出錯:
Compiling resources...
Compiling...
playsound.cpp
dsutil.cpp
dxutil.cpp
Linking...
dsutil.obj : error LNK2001: unresolved external symbol _DirectSoundCreate8@12
Debug/playsound.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
playsound.exe - 2 error(s), 0 warning(s)
記住:此路徑也要提到最上麵,如下圖:
完成以上所有步驟後,編譯通過,心情一下就爽了很多!
上編譯鏈接成功後的圖:
————2011年1月24日淩晨02:14分

 

最後更新:2017-04-02 06:51:35

  上一篇:go 2011年,我的好好計劃今年自己短期和長遠的目標
  下一篇:go magento -- 按某個屬性排序上的一個嚐試