前1、2、3章详见《windows下编译aria2,并搭建eclipse编译调试环境(一)》https://blog.csdn.net/xiaoNature/article/details/124720823
1、下载aria2源码
2、安装编译工具链
3、官方命令行编译(静态库版本)
4、官方命令行编译(动态库版本)
生成配置脚本
生成Makefile
编译(动态库)
验证编译成果物
5、搭建eclipse环境编译及调试
创建并编译wslay工程
创建并编译aria2工程
创建并编译aria2c工程
调试aria2c.exe验证编译成果物
配置静态库调试配置
配置动态库调试配置
调试并验证
4、官方命令行编译(动态库版本)
启动MSYS2 MinGW x86环境进行命令行编译
生成配置脚本按github的Readme说明,首先执行生成配置的命令(时间较长,需耐心等待)
autoreconf -i
执行成功后,即可生成配置脚本configure和其他一些必要文件
生成Makefile按照官方说明在windows上生成Makefile,需要执行mingw-config脚本
但是执行mingw-config脚本官方描述说需要如下库的支持
所以先要安装上述库的依赖到MSYS2中,并且版本均为mingw-w64-x86_64前缀,所有的依赖库安装命令均在Pending Package Updates - MSYS2 Packages网站查找
pacman -S mingw-w64-x86_64-c-ares
pacman -S mingw-w64-x86_64-expat
pacman -S mingw-w64-x86_64-sqlite3
pacman -S mingw-w64-x86_64-zlib
pacman -S mingw-w64-x86_64-libssh2
pacman -S mingw-w64-x86_64-cppunit
全部安装成功后
*此处为动态库的版本,所以需要修改mingw-config文件,将文件中的“ARIA2_STATIC=yes \”替换为“--enable-libaria2 \”即可。
执行生成Makefile的命令(时间很长,需耐心等待)
HOST=x86_64-w64-mingw32 PREFIX=/mingw64 ./mingw-config > config-my.log
执行成功后,即可生成Makefile和其他必要文件
编译(动态库)执行make命令编译(时间非常长,需耐心等待)
make V=1 > make-my.log
编译成功后,即可在src\.libs目录下,生成libaria2-0.dll和aria2c.exe文件
验证编译成果物动态库版本需要所有的依赖库都拷贝到exe目录,才能运行,所以将如下dll从msys64\mingw64\bin拷贝到src\.libs目录中
cmd进入到src\.libs目录,执行验证命令
aria2c.exe https://speedxbu.baidu.com/shurufa/ime/setup/BaiduPinyinSetup_5.8.4.8.exe
执行成功后,百度输入安装包被成功下载
至此aria2的动态库版本编译和验证成功。
5、搭建eclipse环境编译及调试下载目前最新的eclipse的c++版本,版本号为eclipse-cpp-2022-03-R-win32-x86_64
*为了方便使用eclipse编译,需要使用前两章“生成Makefile”步骤生成的config.h文件
启动eclipse.exe(创建工程时使用MinGW GCC的编译工具链)
创建并编译wslay工程该工程为静态库
添加g++宏定义
添加gcc宏定义
DEL_HAVE_CONFIG_H
DLL_EXPORT
PIC
WSLAY_VERSION=1.1.1
添加g++头文件包含路径
添加gcc头文件包含路径
"D:\opensource\aria2-release-1.36.0-eclipse\deps\wslay\lib"
"D:\opensource\aria2-release-1.36.0-eclipse\deps\wslay"
"D:\opensource\aria2-release-1.36.0-eclipse\deps\wslay\lib\includes"
"D:\opensource\msys64\mingw64\include"
在工程中创建src文件夹,以链接的方式导入aria2中的代码文件
wslay_event.c
wslay_frame.c
wslay_net.c
wslay_queue.c
wslay_stack.c
编译Debug和Release两个配置,生成两个版本的libwslay.a文件
创建并编译aria2工程该工程为静态库和动态库两套配置,需要额外创建Debug-dynamic和Releas-dynamic两个配置
添加静态库和动态库g++宏定义
添加静态库和动态库gcc宏定义
HAVE_CONFIG_H
LOCALEDIR=D:\opensource\msys64\mingw64\share\locale
_POSIX_C_SOURCE=1
CARES_STATICLIB
WSLAY_VERSION=1.1.1
添加静态库和动态库g++头文件包含路径
添加静态库和动态库gcc头文件包含路径
"D:\opensource\aria2-release-1.36.0-eclipse\src"
"D:\opensource\aria2-release-1.36.0-eclipse"
"D:\opensource\aria2-release-1.36.0-eclipse\lib"
"D:\opensource\aria2-release-1.36.0-eclipse\intl"
"D:\opensource\aria2-release-1.36.0-eclipse\src\includes"
"D:\opensource\msys64\mingw64\include"
"D:\opensource\aria2-release-1.36.0-eclipse\deps\wslay\lib\includes"
添加动态库连接库文件和包含路径
cares
wsock32
winmm
iphlpapi
psapi
expat
sqlite3
secur32
advapi32
gmp
ssh2
ssl
crypto
gdi32
crypt32
z
wslay
ws2_32
"D:\opensource\msys64\mingw64\lib"
"${workspace_loc:/wslay/Debug}"
在工程中创建src文件夹,以链接的方式导入aria2中的代码文件
a2gmp.cc
A2STR.cc
AbstractAuthResolver.cc
AbstractBtMessage.cc
AbstractCommand.cc
AbstractDiskWriter.cc
AbstractHttpServerResponseCommand.cc
AbstractOptionHandler.cc
AbstractProxyRequestCommand.cc
AbstractProxyResponseCommand.cc
AbstractSingleDiskAdaptor.cc
ActivePeerConnectionCommand.cc
AdaptiveFileAllocationIterator.cc
AdaptiveURISelector.cc
Adler32MessageDigestImpl.cc
AnnounceList.cc
AnnounceTier.cc
AsyncNameResolver.cc
AsyncNameResolverMan.cc
AuthConfig.cc
AuthConfigFactory.cc
AutoSaveCommand.cc
BackupIPv4ConnectCommand.cc
base32.cc
bencode2.cc
BencodeParser.cc
bitfield.cc
BitfieldMan.cc
bittorrent_helper.cc
BtAbortOutstandingRequestEvent.cc
BtAllowedFastMessage.cc
BtAnnounce.cc
BtBitfieldMessage.cc
BtBitfieldMessageValidator.cc
BtCancelMessage.cc
BtCheckIntegrityEntry.cc
BtChokeMessage.cc
BtDependency.cc
BtExtendedMessage.cc
BtFileAllocationEntry.cc
BtHandshakeMessage.cc
BtHandshakeMessageValidator.cc
BtHaveAllMessage.cc
BtHaveMessage.cc
BtHaveNoneMessage.cc
BtInterestedMessage.cc
BtKeepAliveMessage.cc
BtLeecherStateChoke.cc
BtNotInterestedMessage.cc
BtPieceMessage.cc
BtPieceMessageValidator.cc
BtPortMessage.cc
BtPostDownloadHandler.cc
BtRegistry.cc
BtRejectMessage.cc
BtRequestMessage.cc
BtRuntime.cc
BtSeederStateChoke.cc
BtSetup.cc
BtStopDownloadCommand.cc
BtSuggestPieceMessage.cc
BtUnchokeMessage.cc
BufferedFile.cc
ByteArrayDiskWriter.cc
CheckIntegrityCommand.cc
CheckIntegrityDispatcherCommand.cc
CheckIntegrityEntry.cc
Checksum.cc
ChecksumCheckIntegrityEntry.cc
ChunkChecksum.cc
ChunkedDecodingStreamFilter.cc
ColorizedStream.cc
Command.cc
ConnectCommand.cc
console.cc
ConsoleStatCalc.cc
ContentTypeRequestGroupCriteria.cc
Context.cc
ContextAttribute.cc
cookie_helper.cc
Cookie.cc
CookieStorage.cc
CreateRequestCommand.cc
crypto_hash.cc
CUIDCounter.cc
daemon.cc
DefaultAuthResolver.cc
DefaultBtAnnounce.cc
DefaultBtInteractive.cc
DefaultBtMessageDispatcher.cc
DefaultBtMessageFactory.cc
DefaultBtMessageReceiver.cc
DefaultBtProgressInfoFile.cc
DefaultBtRequestFactory.cc
DefaultDiskWriter.cc
DefaultDiskWriterFactory.cc
DefaultExtensionMessageFactory.cc
DefaultPeerStorage.cc
DefaultPieceStorage.cc
DefaultStreamPieceSelector.cc
DHTAbstractMessage.cc
DHTAbstractTask.cc
DHTAnnouncePeerMessage.cc
DHTAnnouncePeerReplyMessage.cc
DHTAutoSaveCommand.cc
DHTBucket.cc
DHTBucketRefreshCommand.cc
DHTBucketRefreshTask.cc
DHTBucketTree.cc
DHTConnectionImpl.cc
DHTEntryPointNameResolveCommand.cc
DHTFindNodeMessage.cc
DHTFindNodeReplyMessage.cc
DHTGetPeersCommand.cc
DHTGetPeersMessage.cc
DHTGetPeersReplyMessage.cc
DHTInteractionCommand.cc
DHTMessage.cc
DHTMessageDispatcherImpl.cc
DHTMessageEntry.cc
DHTMessageFactoryImpl.cc
DHTMessageReceiver.cc
DHTMessageTracker.cc
DHTMessageTrackerEntry.cc
DHTNode.cc
DHTNodeLookupEntry.cc
DHTNodeLookupTask.cc
DHTNodeLookupTaskCallback.cc
DHTPeerAnnounceCommand.cc
DHTPeerAnnounceEntry.cc
DHTPeerAnnounceStorage.cc
DHTPeerLookupTask.cc
DHTPeerLookupTaskCallback.cc
DHTPingMessage.cc
DHTPingReplyMessage.cc
DHTPingTask.cc
DHTQueryMessage.cc
DHTRegistry.cc
DHTReplaceNodeTask.cc
DHTResponseMessage.cc
DHTRoutingTable.cc
DHTRoutingTableDeserializer.cc
DHTRoutingTableSerializer.cc
DHTSetup.cc
DHTTaskExecutor.cc
DHTTaskFactoryImpl.cc
DHTTaskQueueImpl.cc
DHTTokenTracker.cc
DHTTokenUpdateCommand.cc
DHTUnknownMessage.cc
DirectDiskAdaptor.cc
DiskAdaptor.cc
DlAbortEx.cc
DlRetryEx.cc
DNSCache.cc
download_handlers.cc
download_helper.cc
DownloadCommand.cc
DownloadContext.cc
DownloadEngine.cc
DownloadEngineFactory.cc
DownloadFailureException.cc
DownloadHandler.cc
DownloadHandlerConstants.cc
DownloadResult.cc
EvictSocketPoolCommand.cc
Exception.cc
ExpatXmlParser.cc
ExtensionMessageRegistry.cc
FallocFileAllocationIterator.cc
FatalException.cc
FeatureConfig.cc
FeedbackURISelector.cc
File.cc
FileAllocationCommand.cc
FileAllocationDispatcherCommand.cc
FileAllocationEntry.cc
FileEntry.cc
FillRequestGroupCommand.cc
fmt.cc
FtpConnection.cc
FtpDownloadCommand.cc
FtpFinishDownloadCommand.cc
FtpInitiateConnectionCommand.cc
FtpNegotiationCommand.cc
FtpTunnelRequestCommand.cc
FtpTunnelResponseCommand.cc
gai_strerror.c
GeomStreamPieceSelector.cc
GroupId.cc
GrowSegment.cc
GZipDecodingStreamFilter.cc
GZipEncoder.cc
GZipFile.cc
HandshakeExtensionMessage.cc
HaveEraseCommand.cc
help_tags.cc
HttpConnection.cc
HttpDownloadCommand.cc
HttpHeader.cc
HttpHeaderProcessor.cc
HttpInitiateConnectionCommand.cc
HttpListenCommand.cc
HttpProxyRequestCommand.cc
HttpProxyResponseCommand.cc
HttpRequest.cc
HttpRequestCommand.cc
HttpResponse.cc
HttpResponseCommand.cc
HttpServer.cc
HttpServerBodyCommand.cc
HttpServerCommand.cc
HttpServerResponseCommand.cc
HttpSkipResponseCommand.cc
IndexBtMessage.cc
IndexBtMessageValidator.cc
InitiateConnectionCommand.cc
InitiateConnectionCommandFactory.cc
InitiatorMSEHandshakeCommand.cc
InorderStreamPieceSelector.cc
InorderURISelector.cc
InternalARC4Encryptor.cc
InternalMessageDigestImpl.cc
IOFile.cc
IteratableChecksumValidator.cc
IteratableChunkChecksumValidator.cc
json.cc
JsonParser.cc
LibgmpDHKeyExchange.cc
LogFactory.cc
Logger.cc
LongestSequencePieceSelector.cc
LpdDispatchMessageCommand.cc
LpdMessage.cc
LpdMessageDispatcher.cc
LpdMessageReceiver.cc
LpdReceiveMessageCommand.cc
magnet.cc
message_digest_helper.cc
MessageDigest.cc
MetadataInfo.cc
metalink_helper.cc
Metalink2RequestGroup.cc
MetalinkEntry.cc
Metalinker.cc
MetalinkHttpEntry.cc
MetalinkMetaurl.cc
MetalinkParserController.cc
MetalinkParserState.cc
MetalinkParserStateImpl.cc
MetalinkParserStateMachine.cc
MetalinkParserStateV3Impl.cc
MetalinkParserStateV4Impl.cc
MetalinkPostDownloadHandler.cc
MetalinkResource.cc
MSEHandshake.cc
MultiDiskAdaptor.cc
MultiFileAllocationIterator.cc
MultiUrlRequestInfo.cc
NameResolveCommand.cc
NameResolver.cc
Netrc.cc
NetrcAuthResolver.cc
NetStat.cc
Notifier.cc
NsCookieParser.cc
NullSinkStreamFilter.cc
OpenedFileCounter.cc
option_processing.cc
Option.cc
OptionHandler.cc
OptionHandlerException.cc
OptionHandlerFactory.cc
OptionHandlerImpl.cc
OptionParser.cc
paramed_string.cc
Peer.cc
PeerAbstractCommand.cc
PeerAddrEntry.cc
PeerChokeCommand.cc
PeerConnection.cc
PeerInitiateConnectionCommand.cc
PeerInteractionCommand.cc
PeerListenCommand.cc
PeerReceiveHandshakeCommand.cc
PeerSessionResource.cc
PeerStat.cc
Piece.cc
PiecedSegment.cc
PieceHashCheckIntegrityEntry.cc
PieceStatMan.cc
Platform.cc
prefs.cc
PriorityPieceSelector.cc
ProtocolDetector.cc
RandomStreamPieceSelector.cc
Range.cc
RangeBtMessage.cc
RangeBtMessageValidator.cc
RarestPieceSelector.cc
RealtimeCommand.cc
ReceiverMSEHandshakeCommand.cc
RecoverableException.cc
Request.cc
RequestGroup.cc
RequestGroupEntry.cc
RequestGroupMan.cc
RequestSlot.cc
rpc_helper.cc
RpcMethod.cc
RpcMethodFactory.cc
RpcMethodImpl.cc
RpcRequest.cc
RpcResponse.cc
SaveSessionCommand.cc
SeedCheckCommand.cc
SegmentMan.cc
SelectEventPoll.cc
ServerStat.cc
ServerStatMan.cc
SessionSerializer.cc
SftpDownloadCommand.cc
SftpFinishDownloadCommand.cc
SftpNegotiationCommand.cc
SHA1IOFile.cc
ShareRatioSeedCriteria.cc
Signature.cc
SimpleBtMessage.cc
SimpleRandomizer.cc
SingleFileAllocationIterator.cc
SinkStreamFilter.cc
SocketBuffer.cc
SocketCore.cc
SocketRecvBuffer.cc
SpeedCalc.cc
Sqlite3CookieParser.cc
Sqlite3CookieParserImpl.cc
SSHSession.cc
StreamCheckIntegrityEntry.cc
StreamFileAllocationEntry.cc
StreamFilter.cc
strptime.c
TimeA2.cc
TimeBasedCommand.cc
TimedHaltCommand.cc
timegm.c
TimerA2.cc
TimeSeedCriteria.cc
TorrentAttribute.cc
TrackerWatcherCommand.cc
TransferStat.cc
TruncFileAllocationIterator.cc
UDPTrackerClient.cc
UDPTrackerRequest.cc
UnionSeedCriteria.cc
UnknownLengthPieceStorage.cc
UnknownOptionException.cc
uri_split.c
uri.cc
UriListParser.cc
URIResult.cc
util_security.cc
util.cc
UTMetadataDataExtensionMessage.cc
UTMetadataExtensionMessage.cc
UTMetadataPostDownloadHandler.cc
UTMetadataRejectExtensionMessage.cc
UTMetadataRequestExtensionMessage.cc
UTMetadataRequestFactory.cc
UTMetadataRequestTracker.cc
UTPexExtensionMessage.cc
ValueBase.cc
ValueBaseStructParserStateImpl.cc
ValueBaseStructParserStateMachine.cc
version_usage.cc
wallclock.cc
WatchProcessCommand.cc
WebSocketInteractionCommand.cc
WebSocketResponseCommand.cc
WebSocketSession.cc
WebSocketSessionMan.cc
WinConsoleFile.cc
WinTLSContext.cc
WinTLSSession.cc
WrDiskCache.cc
WrDiskCacheEntry.cc
XmlAttr.cc
XmlParser.cc
XmlRpcDiskWriter.cc
XmlRpcRequestParserController.cc
XmlRpcRequestParserStateImpl.cc
XmlRpcRequestParserStateMachine.cc
ZeroBtMessage.cc
编译Debug、Release、Debug-dynamic、Release-dynamic四个配置,生成两个版本的libaria2.a文件、两个版本的libaria2.dll文件
创建并编译aria2c工程该工程为静态库和动态库两套配置,需要额外创建Debug-dynamic和Releas-dynamic两个配置
添加静态库和动态库g++宏定义
添加静态库和动态库gcc宏定义
HAVE_CONFIG_H
LOCALEDIR=D:\opensource\msys64\mingw64\share\locale
_POSIX_C_SOURCE=1
CARES_STATICLIB
WSLAY_VERSION=1.1.1
添加静态库和动态库g++头文件包含路径
添加静态库和动态库gcc头文件包含路径
"D:\opensource\aria2-release-1.36.0-eclipse\src"
"D:\opensource\aria2-release-1.36.0-eclipse"
"D:\opensource\aria2-release-1.36.0-eclipse\lib"
"D:\opensource\aria2-release-1.36.0-eclipse\intl"
"D:\opensource\aria2-release-1.36.0-eclipse\src\includes"
"D:\opensource\msys64\mingw64\include"
"D:\opensource\aria2-release-1.36.0-eclipse\deps\wslay\lib\includes"
添加静态库连接库文件和包含路径
aria2
cares
wsock32
winmm
iphlpapi
psapi
expat
sqlite3
secur32
advapi32
gmp
ssh2
ssl
crypto
gdi32
crypt32
z
wslay
ws2_32
"D:\opensource\msys64\mingw64\lib"
"${workspace_loc:/wslay/Debug}"
"${workspace_loc:/aria2/Debug}"
添加静态库连接选项
-static
添加动态库连接库文件和包含路径
aria2
"${workspace_loc:/aria2/Debug-dynamic}"
在工程中创建src文件夹,以链接的方式导入aria2中的代码文件
main.cc
编译Debug、Release、Debug-dynamic、Release-dynamic四个配置,生成四个版本的aria2c.exe文件
调试aria2c.exe验证编译成果物 配置静态库调试配置添加aria2c调试配置,并添加启动参数
https://speedxbu.baidu.com/shurufa/ime/setup/BaiduPinyinSetup_5.8.4.8.exe
配置动态库调试配置添加aria2c调试配置,并添加启动参数
https://speedxbu.baidu.com/shurufa/ime/setup/BaiduPinyinSetup_5.8.4.8.exehttps://speedxbu.baidu.com/shurufa/ime/setup/BaiduPinyinSetup_5.8.4.8.exe
将如下dll从msys64\mingw64\bin拷贝到aria2c\Debug-dynamic目录中
调试并验证Debug启动aria2c的调试
静态库log
动态库log
调试执行成功后,百度输入安装包被成功下载
在main函数打断点,调试可以正确在断点处,触发中断进入调试
至此,windows下编译aria2,并搭建eclipse编译调试环境的文章编写完成。
接下来就开始研究aria2的磁力下载和DHT的源码,看看有没有可能实现点对点聊天软件的可能。
等待继续。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)