舊版(v2010.??.??)的 Live555 "似乎" 有效能問題,
所以在研究把最新版(2013.01.05)的 Live555 整進原有的 DLL.
先找到 live555 官網, 照方式 build windows 版的 lib
http://www.live555.com/liveMedia/#config-windows
隨後, 把原本 DLL 的 source code 去 link 到這些 lib
結果遇到 redefinition 問題.
主要還是 winsock2.h 裡面一堆資料結構被重複定義.
比較兩版 NetCommon.h,
發現新版在 include "winsock2.h" 之前,
多了 || defined (_MSC_VER) 判斷,
於是試著把他拿掉.
重複定義的問題解決了, 但又產生了新的問題 ...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in libcmt.lib(sprintf.obj)
上網找到類似的問題 ...
http://bbs.csdn.net/topics/50365885
把文章裡面的 libcmtd.lib 改成 libcmt.lib.
解了這個, 還有別的 ...
error LNK2001: unresolved external symbol __argv
再度求助 google ...
http://blog.csdn.net/pbdwadr/article/details/1775675
照文章描述, 定義了 _AFXDLL 之後還是有 compile error,
不過這次就很明確了, 只要再定義 _DLL 就可以了,
所以額外定義了 _DLL.
至此, 原dll link live555 編譯完成的 lib 已無 compiling error 問題
接下來, 就是把 live555 source code 放進 dll source code 資料夾內進行 compile
馬上就遇到問題:
fatal error C1010: unexpected end of file while looking for precompiled header directive
於是使用 git CLI,
sed -i '1i #include <stdafx.h>' *.cpp
一次更新所有的 cpp 檔 (很奇怪, DOS視窗似乎不行)
解決 .cpp 的問題, 但 .c 檔依然有問題.
因為如果 .c檔跟著加上 #include <stdafx.h>
會出現另一個 error:
fatal error C1853: 'XXX.pch' is not a precompiled header file created with this compiler
所以 .c檔不能加這個, 而是要按滑鼠右鍵點選 Settings,
把 Use precompiled header file 改成 Not using precompiled headers
至此, 原dll source code 和 live555 source code 合 build 成同一份 dll, 已經 compile 成功
compile 成功是一回事, run 出什麼結果是另一回事 ... 先到這邊好了 XD
過程中找了很多資料,
雖然最後證明不適用我遇到的情況,
不過還是先記錄幾個,
說不定日後換個平台又遇到了 ... orz
1.
http://stackoverflow.com/questions/1372480/c-redefinition-header-files
2.
http://blog.csdn.net/markman101/article/details/5738473
3.
http://cboard.cprogramming.com/windows-programming/41212-strange-msvc-winsock2-compile-error.html
4.
http://stackoverflow.com/questions/3007312/resolving-lnk4098-defaultlib-msvcrt-conflicts-with