I finally linked Casablanca/CPPRESTSDK with VS17, thanks for this post Statically linking Casablanca/CPPREST SDK and some anothers. 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. I also have these files in lib format in vcpkg-master\installed\x86-windows-static\lib, can I somehow use them instead of dlls?
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. I wanted to link statically to cpprestsdk without three extra DLLs to distribute. 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). I couldn't find a pre-compiled version which used the /MD switch (multi-threaded DLL), but exported as a library. So I had to compile it myself.
My solution:
download vcpkg (https://github.com/microsoft/vcpkg). This is a package C and C++ library package manager. You will need to 'bootstrap' it. See the Quick Start.
install necessary dependencies for cpprestsdk: `vcpkg install --triplet x86-windows zlib openssl boost-system boost-date-time boost-regex boost-interprocess websocketpp brotli
download cpprestsdk from github (https://github.com/Microsoft/cpprestsdk)
generate a Visual Studio solution file (https://github.com/microsoft/cpprestsdk/wiki/How-to-build-for-Windows). I wanted to generate an x86 version, so I had to use the following command cmake ../Release -A win32 -DCMAKE_TOOLCHAIN_F ILE=d:\jw\git\vcpkg\scripts\buildsystems\vcpkg.cmake.
open cpprestsdk.sln solution and do the following for Release and Debug configurations in the cpprest project:
change the configuration type to Static library
change the target file extension to .lib.
build debug and release versions.
I could then use the generated libraries in my solution.
add the cpprestsdk include directory to my project
add the cpprestsdk libraries to the linker Input
add the zlib and openssl libraries from the cpprestsdk packages directory.
add the libraries bcrypt.lib, winhttp.lib and crypt32.lib to the linker Input too (Statically linking Casablanca/CPPREST SDK)
you also need to add the preprocessor flag _NO_ASYNCRTIMP to the project where you use cpprestsdk.
I hope this helps someone save some of the hours I lost getting it to work!
Related
I created a project using freeglut and glew and am attempting to statically link them. Currently when I build the project, I get an exe and two dlls(freeglut32.dll and glew32.dll). I'd like to make it so that I only get the exe.
To install the libraries I used NuGet. (Install-Package freeglut) and (Install-Package glew). NuGet downloads glew.lib to .\packages\glew.1.9.0.1\build\native\lib\v110\x64\Release\static\glew.lib and freeglut to .\packages\freeglut.2.8.1.15\build\native\lib\v110\x64\Release\static\freeglut.lib.
I assume they are the .lib files I wanted because they are both over 1 MB.
In Visual Studio, I went to Linker -> Input -> Additional Dependencies and added the paths of freeglut.lib and glew.lib. I also added #define GLEW_STATIC and #define FREEGLUT_STATIC to my code. Link Library Dependencies is turned on.
Even still, building the project gives me my 654 KB exe along with 224 kb of freeglut.dll and 356 kb of glew32.dll.
How can I make sure it so that glew32.dll and freeglut.dll do not exist and I am just given the single executable?
Edit:
Due to suggestions:
I went to Properties -> Referenced Packages and set freeglut and glew to Static.
You need to build static libraries for glew and freeglut that are compatible with your project settings
Step 1) Download and build vcpkg.exe ( a open source auto packaging tools from Microsoft) and make sure to keep built settings similar to your current project. Later vcpkg will use these settings as the default or intrinsic values.
Step 2) Open PowerShell in administrative mode and go the vcpkg directory
Step 3) Type .\vcpkg install glew:x64-windows-static This tells the packager to build a static library of the project for x64 machine. Repeat for freeglut. Your static libraries are ready for manual linking. Under the vcpkg\ installed\x64-windows-static\ , you can find subdirectories viz lib ( your lib are here), and include directory contains your glew include files.
Step 4) [Optional] If you want to auto link the installed packages to your visual studio C++ projects (available in VS 2015 or later only), type
.\vcpkg integrate install
Many open source windows projects can be auto build using this tool, enjoy.
How can I use libcurl with my project without actually installing it or curl on the system?
I want to make my source-code portable, so that any developer can copy the folder with all sources and other files, run make and compile the program without the need for system level installations.
I am looking for (probably separate) solutions for Linux and for Windows (dll?). If it is possible, provide some standard/official solution and not hack (I'd like to be educated about linking third party libraries)
I've used it on Windows using Visual Studio, all you need to do under Windows:
Download the source
Using CMake generate the project files (when using Visual Studio).
Build the libraries, 3 files will be built: libcurl.lib, libcurl_imp.lib and libcurl.dll
Include curl.h in your project and add the paths to your .lib files
Build your program, put libcurl.dll in the executable folder and it will work.
On Linux it should be a similar process, build the libraries and include them with your source.
You probably want to build a static library out of libcurl and link agains it. Should be pretty straightforward and the process is almost identical on every OS.
I recently downloaded http://boost-log.sourceforge.net/libs/log/doc/html/index.html but I can't seem to find out how to build it. The rest of my boost lib was installed by using the installer, so all I did was selecting the files I wanted to include.
So how do I build Logs? Building for windows is completely new to me and I would really appreciate any help!
EDIT
Merge boost.log in the boost directory structure first.
Did you build boost ? If not, you have to go to your boost directory, run boostrap.sh and then run b2.exe. That will build all boost libraries.
Since you are on Windows, boost supports automatic linking, i.e. you just include the header files and the required libraries will be linked automatically when building your project from Visual Studio.
I have only previously used visual studio for developing c++ but I've just moved to netbeans and am having some issues.
I got mingw installed so that my projects will compile but I dont know how to add external libraries to that. I want to use a static library, not a dll.
The library I specifically am looking at is libpng
I hope this isn't too IDE specific, I'm also looking to know how to prepare the library.
Windows OS.
I figured it out more or less. I used the cmake gui, configured for msys make and mingw g++ and gcc, on the zlib source directory and then ran msys make and make install on the output directory. After that I did the same on libpng, but I had to add some variables to point to the zlib include and library directories within cmake.
Then in netbeans, I right clicked>>properties on my project and added include and lib location for each of the two libraries. I also could have copied the files into my mingw directories.
Now I'm just stuck with this issue.
I tried to write code that was a sample of the Boost test library:
#include <boost/unit_test.hpp>
BOOST_AUTO_TEST_CASE(test)
{
BOOST_CHECK(true);
}
I built the source code, and I got the execution file test.exe. I tried to execute that file, but I got an error message.
The program can't start because boost_unit_test_framework-vc80-mt-1_44.dll is missing from your computer. Try reinstalling the program to fix this problem.
But, I have ready that file on my boost library directory.
What's the problem in this case?
Background:
For my build environment, I use Windows 7 Ultimate x64, and Visual Studio 2005.
So I built boost library by my self, and I got all the libraries for the 64-bit computing system.
Using bjam, and I use the command: bjam --toolset=mvsc-8.0 address-model=64 threading=multi --build-system=complete install on 64-bit command prompt window.
After the build, I set the boost library and header directory in Visual Studio directory path option.
Thank you all!
Make sure that the path to your DLL is included in the "PATH" environment variable. (Or include the DLL in your exe directory if you like). That way the DLL will be found.
You can also choose to use the static versions of the Boost libraries.
Build or download the static libraries and point Visual Studio at those instead. The Boost code will be built into your application (increasing its size some) and you will not need a DLL.
If using CMake to configure your application, you can tell CMake to use the static versions of the Boost libraries using Boost_USE_STATIC_LIBS:
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost ... )
This way, the DLLs will not be required, as the requisite Boost definitions will be built into your application via the static libraries.