What is the difference between lib and debug/lib created by vcpkg - c++

When I Install packages using vcpkg, it creates lib and Debug/lib, in which are the static libraries. but I wonder what is the difference between them, since I can use both of them as the library path in my Visual Studio C++ Project and both ways can build the project successfully...
(I know that in the debug directory, the libs are for debug. But I only add, for example, imgui.lib, to the "Additional Dependencies", and I set debug/lib(which only has imguid.lib) as the library path, the projected also can be built successfully...How does VS know that imguid.lib is the imgui.lib?)
Root Directory
lib
debug/lib

Related

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. 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!

Visual Studio Static Link (freeglut, glew)

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.

Shared libraries on Windows - dependencies using wrong dll

I have a C++ code that uses gdal as library. Compiled with intel c++ compiler 16 on visual studio 2013.
In the configuration, I specify the gdal library path and library file to link with:
Additional Library Directories: C:\OSGeo4W64\lib (where gdal_i.lib is)
Additional Dependencies: gdal_i.lib
It used to work a few months ago, but something must have changed in my system. Now, when I try my executable, I get a popup with error:
The ordinal 361 could not be located in the dynamic link library SSLEAY32.dll
I can fix it by copying the SSLEAY32.dll from the gdal folder in the executable folder or by removing any call to gdal from my code, but I would like to fix my system rather. How to tell Windows to look in the right directory (I played with the PATH a lot with no success).
Using Dependency Walker, it seems that the gdal.dll is not the one from my OSGEO path, but is taken from my miniconda install. Is there a clean way to fix it? I though that if a library had its dependencies in the same folder, those ones would be used.
EDIT: Solution, thanks to Naidu's answer:
add C:\OSGeo4W64\bin; at the beginning of my path, such that the correct gdal202.dll is used in priority.
but now python does not start anymore, because it is not selecting its own gdal libraries in the miniconda folder but rather in OSGeo4W64... I can get one or the other working with the same path but not both
solution place first in the PATH the directory of Miniconda python executable, then OSGeo4W64 libraries path, then Miniconda libraries path
Additional Library Directories will helps in only for looking up the .lib (static libraries) files, but not for DLLs.
The DLLs are looked up as shown in the order in below link.
https://msdn.microsoft.com/en-us/library/7d83bc18.aspx
So now, if your intended DLL is to be picked up, then place the DLL in any of the locations in first 4 steps said in above link..... or you can edit the PATH variable of user variables of Environment variables, with your DLL location.
Because
User variables take precedence over system environment variables. The
user path is appended to the system path.

CMake can not find boost libs

I am trying to build C++ progect uses boost and Cmake, but I have a problem with some libs
I already added paths to "Environment Variables"
And even added boost folder to "Path"
But it doesn't work. May somebody give an advice!?
Your BOOST_LIBRARYDIR should be a path to folder containing build boost libraries (typically something like boost_1_64\stage\lib filled with .dll and .lib files) while boost_1_64\libs contains source code. You need to build boost first and then set BOOST_LIBRARYDIR accordingly.

CLion MinGW freeglut opengl library linking

I am trying to follow this guide to configure my freeglut and opengl .
I am used to the intellij enviroment via android studio so i would like to work in Clion.
I am stuck at the part....
Libraries: the OpenGL library "libopengl32.a", GLU library
"libglu32.a" and GLUT library "libfreeglut.a" are kept in
"\lib" directory. This directory is in the implicit
library-path. Nonetheless, we need to include these libraries in
linking. They shall be referred to as "opengl32", "glu32", "freeglut"
without the prefix "lib" and suffix ".a".
how do i add this in Clion ?
CLion uses cmake for building your projects. Follow below steps to add link libraries to your project.
Open the CMakeLists.txt file in your project and add,
target_link_libraries(<target executable> libopengl32.a libglu32.a libfreeglut.a)
to that file.
target executable is the executable which you want to link these libraries. Normally this is your project name as defined in add_executable.
Note: Cmake will show you an error if you place target_link_libraries before add_executable.