织梦CMS - 轻松建站从此开始!

罗索实验室

当前位置: 主页 > 流媒体开发 > 大杂烩 >

在VS2005下编译emule

罗索客 发布于 2007-01-31 10:00 点击:次 
优秀代码学习:eMule0.47a 编译环境:Microsoft Visual C++ .NET 2005 英文版(VSTS)。eMule版本:0.47a
TAG:

编译环境:Microsoft Visual C++ .NET 2005 英文版(VSTS)
eMule版本:0.47a

[1]下载源代码和支持库
1.下载eMule v0.47a 源代码
http://sourceforge.net/projects/emule
2.Crypto++ v5.23
http://sourceforge.net/cvs/?group_id=6152

(源文件需从CVS中下载最新的版本,否则不能通过编译)
3.zlib v1.2.3
http://www.zlib.net/
4.libpng
http://sourceforge.net/projects/libpng/
5.ResizableLib 1.3.8
http://sourceforge.net/projects/resizablelib/

6 DirectX9 SDK

注意DirectX9.0c中不包含directshow部分需另外下载

[2]编译eMule所需要的库。
注意事项:每一个库编译时Release和Dubug方式应各编译一次。

Release时Run-Time Libaray都统一用用Multi-threaded (/MT)

Debug时 Run-Time Libaray 都统一用用 (/MTD)

其中:zlib,libpng和crypto库

编译后的*.lib文件应分别放入./Debug 和./Release文件夹中

ResizableLib后产生的lib文件放入./DebugUnicode ,./ReleaseUnicode文件夹中

[3]编译emule

解压emule源文件后产生如下目录:

eMule0.47a-Sources

…….. id3lib 库文件,需先编译,方法同上

…….. srchybrid //emule源文件,最后编译

将libpng等库目录拷入eMule0.47a-Sources目录

最后目录结构如下:

eMule0.47a-Sources

…….. id3lib 库文件,需先编译,方法同上

…….. srchybrid //emule源文件,最后编译

……………CxImage //需先编译

……...png

….Debug/png.lib

… Release/png.lib

………Zlib

…………….Debug/zlib.lib

…………….Release/zlib.lib

在工程设置中的Additional include directories ,把directXsdk的include目录添加进去

以上都作好了以后就可以编译emule了,编译时可以先把 warning level 设成 OFF

编译时大概有40多个错误。

修改如下:1.把如i为定义之类的简单错误改正

2.对GetLocalTm函数的处理

time_t tLast=safe_mktime(last.GetLocalTm());//错误处

struct tm tmp;//新加

time_t tLast=safe_mktime(last.GetLocalTm(&tmp));//修改

3. 修改AfxBeginMsgMapTemplate.h文件

在#else

#error "MFC version not supported"

前添加如下内容

#elif _MFC_VER == 0x0800

#define BEGIN_MESSAGE_MAP_TEMPLATE(templateList, templateClass, theClass, baseClass) \\

PTM_WARNING_DISABLE \\

templateList const AFX_MSGMAP* templateClass::GetMessageMap() const \\

{ return theClass::GetThisMessageMap(); } \\

templateList const AFX_MSGMAP* PASCAL templateClass::GetThisMessageMa() \\

{ \\

typedef theClass ThisClass; \\

typedef baseClass TheBaseClass; \\

static const AFX_MSGMAP_ENTRY _messageEntries[] = \\

{

4.修改DialogMinTrayBtn.h文件

afx_msg UNIT OnNcHitTest(CPoint point);改成

afx_msg LRESULT OnNcHitTest(CPoint point);

5. 修改DialogMinTrayBtn.cpp文件

TEMPLATE UNIT CDialogMinTrayBtn<BASE>::OnNcHitTest(CPoint point)改成

TEMPLATE LRESULT CDialogMinTrayBtn<BASE>::OnNcHitTest(CPoint point)

6. emule.cpp

修改(不太确定,这样会不会出问题):

#if _MFC_VER==0x0700 || _MFC_VER==0x0710 || _MFC_VER==0x0800 //此处新添

void __cdecl __AfxSocketTerm()

{

#if defined(_AFXDLL) && (_MFC_VER==0x0700 || _MFC_VER==0x0710)

VERIFY( WSACleanup() == 0 );

#else

_AFX_SOCK_STATE* pState = _afxSockState.GetData();

if (pState->m_pfnSockTerm != NULL){

VERIFY( WSACleanup() == 0 );

pState->m_pfnSockTerm = NULL;

}

#endif

}

#else

#error "You are using an MFC version which may require a special version of the above function!"

#endif

7. SearchManager.cpp

这里好像是个bug,该动如下

void CSearchManager::JumpStart()

{

// Find any searches that has stalled and jumpstart them.

// This will also prune all searches.

int flag=0;

time_t tNow = time(NULL);

for (SearchMap::iterator itSearchMap = m_mapSearches.begin(); itSearchMap =m_mapSearches.end(); )

{

flag=0;

// Each type has it's own criteria for being deleted or jumpstarted.

switch(itSearchMap->second->GetSearchTypes())

{

case CSearch::FILE:

{

if (itSearchMap->second->m_tCreated + SEARCHFILE_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHFILE_TOTAL || itSearchMap->second->m_tCreated + SEARCHFILE_LIFETIME - SEC(20) < tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::KEYWORD:

{

if (itSearchMap->second->m_tCreated + SEARCHKEYWORD_LIFETIME < tNow)

{

// Tell GUI that search ended

if (theApp.emuledlg && theApp.emuledlg->searchwnd)

theApp.emuledlg->searchwnd->CancelKadSearch(itSearchMap->second->GetSearchID());

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHKEYWORD_TOTAL || itSearchMap->second->m_tCreated + SEARCHKEYWORD_LIFETIME - SEC(20) < tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::NOTES:

{

if (itSearchMap->second->m_tCreated + SEARCHNOTES_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHNOTES_TOTAL || itSearchMap->second->m_tCreated + SEARCHNOTES_LIFETIME - SEC(20) < tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::FINDBUDDY:

{

if (itSearchMap->second->m_tCreated + SEARCHFINDBUDDY_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHFINDBUDDY_TOTAL || itSearchMap->second->m_tCreated + SEARCHFINDBUDDY_LIFETIME - SEC(20) < tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::FINDSOURCE:

{

if (itSearchMap->second->m_tCreated + SEARCHFINDSOURCE_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHFINDSOURCE_TOTAL || itSearchMap->second->m_tCreated + SEARCHFINDSOURCE_LIFETIME - SEC(20) < tNow)

itSearchMap->second-&g[FS:PAGE]t;PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::NODE:

{

if (itSearchMap->second->m_tCreated + SEARCHNODE_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::NODECOMPLETE:

{

if (itSearchMap->second->m_tCreated + SEARCHNODE_LIFETIME < tNow)

{

// Tell Kad that it can start publishing.

CKademlia::GetPrefs()->SetPublish(true);

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if ((itSearchMap->second->m_tCreated + SEARCHNODECOMP_LIFETIME < tNow) && (itSearchMap->second->GetAnswers() >= SEARCHNODECOMP_TOTAL))

{

// Tell Kad that it can start publishing.

CKademlia::GetPrefs()->SetPublish(true);

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::STOREFILE:

{

if (itSearchMap->second->m_tCreated + SEARCHSTOREFILE_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHSTOREFILE_TOTAL || itSearchMap->second->m_tCreated + SEARCHSTOREFILE_LIFETIME - SEC(20) < tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::STOREKEYWORD:

{

if (itSearchMap->second->m_tCreated + SEARCHSTOREKEYWORD_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHSTOREKEYWORD_TOTAL || itSearchMap->second->m_tCreated + SEARCHSTOREKEYWORD_LIFETIME - SEC(20)< tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

case CSearch::STORENOTES:

{

if (itSearchMap->second->m_tCreated + SEARCHSTORENOTES_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else if (itSearchMap->second->GetAnswers() >= SEARCHSTORENOTES_TOTAL || itSearchMap->second->m_tCreated + SEARCHSTORENOTES_LIFETIME - SEC(20)< tNow)

itSearchMap->second->PrepareToStop();

else

itSearchMap->second->JumpStart();

break;

}

default:

{

if (itSearchMap->second->m_tCreated + SEARCH_LIFETIME < tNow)

{

delete itSearchMap->second;

itSearchMap = m_mapSearches.erase(itSearchMap);

flag=1;

}

else

itSearchMap->second->JumpStart();

break;

}

}

if (flag==0)

++itSearchMap;

}

}

(iwgh)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www1.rosoo.net/a/200701/6555.html]
本文出处:网络博客 作者:iwgh
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
相关文章
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容