[英]How to statically link cpprest without dll files in VS project?
I finally linked Casablanca/CPPRESTSDK with VS17, thanks for this post Statically linking Casablanca/CPPREST SDK and some anothers. 最后,我将Casablanca / CPPRESTSDK与VS17链接在一起,感谢这篇文章静态地将Casablanca / CPPRESTSDK与其他链接。 But now I see, that when I start project, for some reason VS automatically generates 3 DLL files
zlib1.dll
SSLEAY32.dll
LIBEAY32.dll
in folder with .exe, but I actually linked staticly for not to have them at all. 但是现在我看到,当我开始项目时,由于某种原因,VS
LIBEAY32.dll
在.exe文件夹中自动生成3个DLL文件zlib1.dll
SSLEAY32.dll
LIBEAY32.dll
,但是我实际上是静态链接的,根本没有它们。 I also have these files in lib format in vcpkg-master\\installed\\x86-windows-static\\lib
, can I somehow use them instead of dlls? 我在
vcpkg-master\\installed\\x86-windows-static\\lib
也有lib格式的这些文件,我可以以某种方式代替dll使用它们吗?
I had the same problem. 我有同样的问题。 I have a Visual Studio solution with projects using MFC in a shared DLL and using the multi-threaded DLL runtime library.
我有一个Visual Studio解决方案,其中的项目使用共享DLL中的MFC并使用多线程DLL运行时库。 I wanted to link statically to cpprestsdk without three extra DLLs to distribute.
我想静态链接到cpprestsdk,而无需分发三个额外的DLL。 Linking to the static version of cpprestsdk wasn't working: I couldn't link because of conflicting runtime libraries (
/MT
- multithreaded and /MD
- multi-threaded DLL). 链接到cpprestsdk的静态版本不起作用:由于运行时库冲突(
/MT
多线程和/MD
多线程DLL),我无法链接。 I couldn't find a pre-compiled version which used the /MD
switch (multi-threaded DLL), but exported as a library. 我找不到使用
/MD
开关(多线程DLL)但导出为库的预编译版本。 So I had to compile it myself. 所以我必须自己编译。
My solution: 我的解决方案:
vcpkg
( https://github.com/microsoft/vcpkg ). vcpkg
( https://github.com/microsoft/vcpkg )。 This is a package C and C++ library package manager. cmake ../Release -A win32 -DCMAKE_TOOLCHAIN_F ILE=d:\\jw\\git\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake
. cmake ../Release -A win32 -DCMAKE_TOOLCHAIN_F ILE=d:\\jw\\git\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake
。 cpprestsdk.sln
solution and do the following for Release and Debug configurations in the cpprest
project: cpprestsdk.sln
解决方案,并对cpprest
项目中的Release和Debug配置执行以下操作:
.lib
. .lib
。 I could then use the generated libraries in my solution. 然后,我可以在解决方案中使用生成的库。
packages
directory. packages
目录添加zlib和openssl库。 bcrypt.lib
, winhttp.lib
and crypt32.lib
to the linker Input too ( Statically linking Casablanca/CPPREST SDK ) bcrypt.lib
, winhttp.lib
和crypt32.lib
到链接器输入( 静态链接Casablanca / CPPREST SDK ) _NO_ASYNCRTIMP
to the project where you use cpprestsdk. _NO_ASYNCRTIMP
添加到使用cpprestsdk的项目中。 I hope this helps someone save some of the hours I lost getting it to work! 我希望这可以帮助某人节省我失去的一些工作时间!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.