QBittorrent編譯過程分析
阿新 • • 發佈:2019-02-07
編譯 QBittorrent需要兩個步驟:
1、依賴庫的編譯
2、qBittorrent本身的編譯。
這裡概要講述第二步(很久以前做了第一步,現在忘了。過程很複雜)。
這裡使用的IDE環境是 QtCreator 2.5 , 編譯使用的是VS2010的庫,所以QT版本是VS2010的版本。
依賴庫:
- libtorrent (v0.16.1)
- Qt (4.8.1)
- Boost (1.49.0)
- MSVC 2010
當依賴庫解決之後,就可以進行編譯了。
首先必須下載最新的qbittorrent原始碼,比如3.0.6的原始碼。
需要修改的幾個地方:
1、winconf.pri
2、winconf-msvc.pri
這裡 是各種依賴庫和標頭檔案的設定。
下面是一個 例子:
winconf-msvc.pri:
RC_FILE = qbittorrent.rc # Enable Wide characters DEFINES += TORRENT_USE_WPATH #Adapt the lib names/versions accordingly CONFIG(debug, debug|release) { LIBS += libtorrentd.lib \ libboost_system-vc90-mt-gd.lib \ libboost_filesystem-vc90-mt-gd.lib \ libboost_thread-vc90-mt-gd.lib } else { LIBS += libtorrent.lib \ libboost_filesystem-vc100-mt-1_47.lib \ libboost_system-vc100-mt-1_47.lib \ libboost_thread-vc100-mt-1_47.lib } LIBS += advapi32.lib shell32.lib LIBS += libeay32.lib ssleay32.lib LIBS += PowrProf.lib
下面是 winconf.pri:
# Adapt these paths on Windows INCLUDEPATH += $$quote(D:/buildings/boost_1_47_0) INCLUDEPATH += $$quote(D:/buildings/libtorrent-rasterbar-0.16.1/include) INCLUDEPATH += $$quote(D:/buildings/openssl-1.0.1c/include) #Point this to the boost lib folder LIBS += $$quote(-LD:/buildings/openssl-1.0.1c/out32dll) LIBS += $$quote(-LD:/buildings/libtorrent-rasterbar-0.16.1/bin/msvc-10.0/release/boost-source/encryption-openssl/geoip-static/link-static/threading-multi) LIBS += $$quote(-LD:/buildings/boost_1_47_0/stage/lib) # LIBTORRENT DEFINES DEFINES += BOOST_ALL_NO_LIB DEFINES += BOOST_ASIO_HASH_MAP_BUCKETS=1021 DEFINES += BOOST_ASIO_SEPARATE_COMPILATION DEFINES += BOOST_EXCEPTION_DISABLE DEFINES += BOOST_SYSTEM_STATIC_LINK=1 DEFINES += TORRENT_USE_OPENSSL DEFINES += UNICODE DEFINES += _UNICODE DEFINES += WIN32 DEFINES += _WIN32 DEFINES += WIN32_LEAN_AND_MEAN DEFINES += _WIN32_WINNT=0x0500 DEFINES += _WIN32_IE=0x0500 DEFINES += _CRT_SECURE_NO_DEPRECATE DEFINES += _SCL_SECURE_NO_DEPRECATE DEFINES += __USE_W32_SOCKETS DEFINES += _FILE_OFFSET_BITS=64 DEFINES += WITH_SHIPPED_GEOIP_H CONFIG(debug, debug|release) { DEFINES += TORRENT_DEBUG } else { DEFINES += NDEBUG } win32-g++ { include(winconf-mingw.pri) } else { include(winconf-msvc.pri) } DEFINES += WITH_GEOIP_EMBEDDED message("On Windows, GeoIP database must be embedded.")