赞
踩
因为想着编译/MT版本,所以就手动编译了Drogon,记录下。
地址:Drogon
std::filesystem
时才需要安装;准备工具:Cmake, Git, Visual Stutio,
先下载源码
- cd $WORK_PATH
- git clone https://github.com/drogonframework/drogon
- cd drogon
- git submodule update --init
依赖不用conan和vcpkg安装 自己编译 /MT版本
- git clone https://github.com/open-source-parsers/jsoncpp
- cd jsoncpp
- #修改CMakeLists.txt
- BUILD_SHARED_LIBS 改为OFF
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
下面使用vs2022打开编译即可
git clone -b master https://github.com/madler/zlib.git
使用Cmake也可以,直接使用vs2022新建工程将头文件添加库目录,将src添加进工程,选择库lib
代码生成选择/MT 编译即可。
- git clone https://github.com/c-ares/c-ares
- cd c-ares
- #修改CMakeLists.txt
- CARES_STATIC ON
- CARES_SHARED OFF
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
使用vs2022打开编译即可
- git clone https://github.com/google/brotli
- cd brotli
- #修改CMakeLists.txt
- BUILD_SHARED_LIBS OFF
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
使用vs2022打开编译即可
直接下载二进制安装文件,安装后头文件和库文件copy出来即可。
地址:postgresql 下载地址:postgresql-downloads mariadb
- git clone https://github.com/redis/hiredis
- cd hiredis
- #修改CMakeLists.txt
- BUILD_SHARED_LIBS OFF
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
使用vs2022打开编译即可
注:预处理器 内容为
- %(PreprocessorDefinitions)
- WIN32
- _WINDOWS
- NDEBUG
- _CRT_SECURE_NO_WARNINGS
- WIN32_LEAN_AND_MEAN
- CMAKE_INTDIR="Release"
- hiredis_EXPORTS
下载版本为 Source Code 中的 sqlite-amalgamation 其中 sqlite-autoconf这个源码要tcl辅助编译。
源码共4个文件两个c文件两个头文件
新建工程,类型库文件lib 运行库/MT
将c文件添加至工程头文件添加库目录编译即可。
git clone https://github.com/jbeder/yaml-cpp
使用 cmake-gui打开
YAML_CPP_BUILD_CONTRIB
YAML_CPP_BUILD_TOOLS
生成工程文件后,使用vs2022打开编译即可
- git clone https://github.com/google/googletest
- cd googletest
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release ..
重头戏,开始编译Drogon
新建工程文件,分别添加三个项目
将源文件添加至对应的项目中,设置头文件引用库目录,添加链接器库文件编译。
本文源码目录如下
项目包含如下:
源文件
- <ItemGroup>
- <ClCompile Include="..\..\drogon\lib\src\AccessLogger.cc" />
- <ClCompile Include="..\..\drogon\lib\src\AOPAdvice.cc" />
- <ClCompile Include="..\..\drogon\lib\src\CacheFile.cc" />
- <ClCompile Include="..\..\drogon\lib\src\ConfigAdapterManager.cc" />
- <ClCompile Include="..\..\drogon\lib\src\ConfigLoader.cc" />
- <ClCompile Include="..\..\drogon\lib\src\Cookie.cc" />
- <ClCompile Include="..\..\drogon\lib\src\DrClassMap.cc" />
- <ClCompile Include="..\..\drogon\lib\src\drogon_test.cc" />
- <ClCompile Include="..\..\drogon\lib\src\DrTemplateBase.cc" />
- <ClCompile Include="..\..\drogon\lib\src\FiltersFunction.cc" />
- <ClCompile Include="..\..\drogon\lib\src\FixedWindowRateLimiter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\GlobalFilters.cc" />
- <ClCompile Include="..\..\drogon\lib\src\Histogram.cc" />
- <ClCompile Include="..\..\drogon\lib\src\Hodor.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpAppFrameworkImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpBinder.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpClientImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpControllersRouter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpFileImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpFileUploadRequest.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpRequestImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpRequestParser.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpResponseImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpResponseParser.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpServer.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpSimpleControllersRouter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpUtils.cc" />
- <ClCompile Include="..\..\drogon\lib\src\HttpViewData.cc" />
- <ClCompile Include="..\..\drogon\lib\src\IntranetIpFilter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\JsonConfigAdapter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\ListenerManager.cc" />
- <ClCompile Include="..\..\drogon\lib\src\LocalHostFilter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\MultiPart.cc" />
- <ClCompile Include="..\..\drogon\lib\src\NotFound.cc" />
- <ClCompile Include="..\..\drogon\lib\src\PluginsManager.cc" />
- <ClCompile Include="..\..\drogon\lib\src\PromExporter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\RangeParser.cc" />
- <ClCompile Include="..\..\drogon\lib\src\RateLimiter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\RealIpResolver.cc" />
- <ClCompile Include="..\..\drogon\lib\src\Redirector.cc" />
- <ClCompile Include="..\..\drogon\lib\src\SecureSSLRedirector.cc" />
- <ClCompile Include="..\..\drogon\lib\src\SessionManager.cc" />
- <ClCompile Include="..\..\drogon\lib\src\SlashRemover.cc" />
- <ClCompile Include="..\..\drogon\lib\src\SlidingWindowRateLimiter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\StaticFileRouter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\TaskTimeoutFlag.cc" />
- <ClCompile Include="..\..\drogon\lib\src\TokenBucketRateLimiter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\Utilities.cc" />
- <ClCompile Include="..\..\drogon\lib\src\WebSocketClientImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\WebSocketConnectionImpl.cc" />
- <ClCompile Include="..\..\drogon\lib\src\WebsocketControllersRouter.cc" />
- <ClCompile Include="..\..\drogon\lib\src\YamlConfigAdapter.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisClientImpl.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisClientLockFree.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisClientManager.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisConnection.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisResult.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisSubscriberImpl.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\RedisTransactionImpl.cc" />
- <ClCompile Include="..\..\drogon\nosql_lib\redis\src\SubscribeContext.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\ArrayParser.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\Criteria.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbClient.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbClientImpl.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbClientLockFree.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbClientManager.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbConnection.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\DbListener.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\Exception.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\Field.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\mysql_impl\MysqlConnection.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\mysql_impl\MysqlResultImpl.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\postgresql_impl\PgConnection.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\postgresql_impl\PgListener.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\postgresql_impl\PostgreSQLResultImpl.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\RestfulController.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\Result.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\Row.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\SqlBinder.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\sqlite3_impl\Sqlite3Connection.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\sqlite3_impl\Sqlite3ResultImpl.cc" />
- <ClCompile Include="..\..\drogon\orm_lib\src\TransactionImpl.cc" />
- <ClCompile Include="..\..\drogon\third_party\mman-win32\mman.c" />
- </ItemGroup>
头文件
项目属性---c/c++---常规---附加包含目录
地址根据自己存放源代码目录为准!!!!!!
..\..\drogon\third_party\mman-win32;..\..\drogon\nosql_lib\redis\inc;..\..\drogon\orm_lib\inc;..\..\drogon\trantor;..\..\drogon\lib\inc;..\..\drogon\lib\src;..\..\drogon;..\..\drogon\orm_lib\src\mysql_impl;%(AdditionalIncludeDirectories)
预处理器
%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;USE_BROTLI;DBUG_OFF;USE_REDIS;CMAKE_INTDIR="Release";HAS_YAML_CPP;YAML_CPP_STATIC_DEFINE
代码生成--运行库 /MT
所有选项--附加选项
%(AdditionalOptions) /external:I "..\..\..\3rdsdk\jsoncpp\include" /external:I "..\..\..\3rdsdk\brotli\include" /external:I "..\..\..\3rdsdk\postgresql\include" /external:I "..\..\..\3rdsdk\sqlite3\include" /external:I "..\..\..\3rdsdk\hiredis\include" /external:I "..\..\..\3rdsdk\zlib\include" /external:I "..\..\..\3rdsdk\yaml-cpp\include" /external:I "..\..\..\3rdsdk\mariadb\include\mysql" /external:I "..\..\..\3rdsdk\yaml-cpp\include" /utf-8 /Zc:__cplusplus
文档管理程序---所有选项
附加依赖项
..\..\..\3rdsdk\yaml-cpp\lib\yaml-cpp.lib
源文件
- <ItemGroup>
- <ClCompile Include="..\..\drogon\third_party\wepoll\Wepoll.c" />
- <ClCompile Include="..\..\drogon\trantor\net\Channel.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\EventLoop.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\EventLoopThread.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\EventLoopThreadPool.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\InetAddress.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\Acceptor.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\Connector.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\NormalResolver.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\Poller.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\poller\EpollPoller.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\poller\KQueue.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\poller\PollPoller.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\Socket.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\TcpConnectionImpl.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\Timer.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\TimerQueue.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\inner\tlsprovider\OpenSSLProvider.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\TcpClient.cc" />
- <ClCompile Include="..\..\drogon\trantor\net\TcpServer.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\AsyncFileLogger.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\ConcurrentTaskQueue.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\crypto\openssl.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\Date.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\Logger.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\LogStream.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\MsgBuffer.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\SerialTaskQueue.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\TimingWheel.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\Utilities.cc" />
- <ClCompile Include="..\..\drogon\trantor\utils\WindowsSupport.cc" />
- </ItemGroup>
头文件
项目属性---c/c++---常规---附加包含目录
地址根据自己存放源代码目录为准!!!!!!
..\..\drogon\trantor;..\..\drogon;..\..\drogon\third_party\wepoll;..\..\drogon\trantor\utils;..\..\drogon\trantor\net;..\..\drogon\trantor\net\inner;%(AdditionalIncludeDirectories)
预处理器
%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;USE_OPENSSL;TRANTOR_TLS_PROVIDER=OpenSSL;CMAKE_INTDIR="Release";HAS_YAML_CPP
代码生成--运行库 /MT
所有选项--附加选项
%(AdditionalOptions) /external:I "..\..\..\3rdsdk\openssl\include" /utf-8 /Zc:__cplusplus
源文件
- <ItemGroup>
- <ClCompile Include="..\..\drogon\drogon_ctl\cmake.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\cmd.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\config_json.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\config_yaml.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_controller.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_filter.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_model.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_plugin.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_project.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\create_view.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\demoMain.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\filter_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\filter_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\gitignore.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\help.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\main.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\model_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\model_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\model_json.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\plugin_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\plugin_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\press.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_base_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_base_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_custom_cc.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_custom_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\restful_controller_h.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\test_cmake.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\test_main.cc" />
- <ClCompile Include="..\..\drogon\drogon_ctl\version.cc" />
- </ItemGroup>
头文件
项目属性---c/c++---常规---附加包含目录
地址根据自己存放源代码目录为准!!!!!!
..\..\drogon\third_party\mman-win32;..\..\drogon\nosql_lib\redis\inc;..\..\drogon\orm_lib\inc;..\..\drogon\trantor;..\..\drogon\lib\inc;..\..\drogon\lib\src;..\..\drogon;..\..\drogon\trantor\utils;..\..\drogon\trantor\net;..\..\drogon\trantor\net\inner;..\..\drogon\orm_lib\src\mysql_impl;%(AdditionalIncludeDirectories)
预处理器
%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;USE_BROTLI;DBUG_OFF;USE_REDIS;CMAKE_INTDIR="Release";HAS_YAML_CPP
代码生成--运行库 /MT
附加选项
%(AdditionalOptions) /external:I "..\..\..\3rdsdk\jsoncpp\include" /external:I "..\..\..\3rdsdk\mariadb\include\mysql" /utf-8 /Zc:__cplusplus
连接器--附加库目录
$(outputpath);%(AdditionalLibraryDirectories)
输入
ws2_32.lib;Rpcrt4.lib;iphlpapi.lib;Crypt32.lib;Secur32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;drogon.lib;trantor.lib;..\..\..\3rdsdk\openssl\lib\libcrypto.lib;..\..\..\3rdsdk\openssl\lib\libssl.lib;..\..\..\3rdsdk\zlib\lib\zlib.lib;..\..\..\3rdsdk\hiredis\lib\hiredis.lib;..\..\..\3rdsdk\sqlite3\lib\sqlite3.lib;..\..\..\3rdsdk\postgresql\lib\libpq.lib;..\..\..\3rdsdk\brotli\lib\brotlicommon.lib;..\..\..\3rdsdk\brotli\lib\brotlidec.lib;..\..\..\3rdsdk\brotli\lib\brotlienc.lib;..\..\..\3rdsdk\jsoncpp\lib\jsoncpp.lib;..\..\..\3rdsdk\mariadb\lib\mariadbclient.lib;..\..\..\3rdsdk\mariadb\lib\mysqlservices.lib;%(AdditionalDependencies)
忽略待定默认库
%(IgnoreSpecificDefaultLibraries)
OK大功告成Enjoy!!!
备注:使用conan管理依赖库,想要/MT版本的在设置前添加 compiler.runtime=static即可。
conan install .. -s compiler="msvc" -s compiler.version=193 -s compiler.cppstd=17 -s build_type=Release --output-folder . --build=missing -s compiler.runtime=static
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。