using OpenSSL in Visual Studio 2012 - c++

I have downloaded the latest release version of Openssl from http://www.openssl.org/source/
I would like to use it in Visual Studio 2012, especially getting the md5/sha-1 hash of a file, but I can not include / setup the environment with the openssl library. To be honest I got confused what to include, and where, however I have read the README-s.
I'm getting this error.
Error 1 error LNK2019: unresolved external symbol _MD5_Init referenced in function _main
So my question is, I have downloaded the latest release (openssl-1.0.1e.tar.gz), what should I config in VS2012 to be able to use the lib? Thanks!
UPDATE
This question helped me also in finding the solution. Boost SSL with Visual Studio 2010 and OpenSSL
The steps required to use the openSSL lib with VS2012:
download and install a version (I have 64bit OS, however I installed 32bit openssl) from http://slproweb.com/products/Win32OpenSSL.html.
New project in VS, then Configuration Properties/C/C++/General/Additional Include Directories: openssl include folder (C:\OpenSSL-Win32\include)
Linker/General/Additional Library Directiories: C:\OpenSSL-Win32\lib
Linker/Input/Additional Dependencies :
libeay32.lib libeay32MTd.lib libeay32MT.lib libeay32MDd.lib
libeay32MD.lib ssleay32.lib ssleay32MTd.lib ssleay32MT.lib
ssleay32MDd.lib ssleay32MD.lib
(It was written that I need to only add that one which matches with C/C++/Code Generation/Runtime Library, but It works me this way.)
Copy theese files into current VS folder /VC/lib

What compiler did you use to compile OpenSSL? Did you use MinGW? If so, make sure you don't strip them (or just with --strip-unneeded) otherwise import symbols will be stripped. Do the header and lib version match?
Maybe you want to try pre built ones from: http://slproweb.com/products/Win32OpenSSL.html those work for sure.

Related

After Building OpenSSL with VS2017 getting some Link Errors. " OPENSSL_init_ssl referenced in function _main "?

#include "pch.h"
#include <iostream>
#include <openssl\ssl.h>
#include <openssl\err.h>
#include <openssl\conf.h>
int main()
{
SSL_library_init();
SSL_load_error_strings();
}
OpenSSL DLL Throws some errors
Getting the following error after built openssl in vs2017
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _OPENSSL_init_ssl referenced in function _main
For OpenSSL 1.0, building a program on Windows require linking with libeay32.lib and ssleay32.lib. You can find these libraries in the out32dll or out32 folder of your OpenSSL folder depending on how you built it. OpenSSL 1.1 might have a different lib name for these libraries.
Also, if you built these libraries as DLLs, you need to copy over libeay32.dll and ssleay32.dll into the same folder as your EXE or have them in your PATH in order for the program to run.
Source : Building libcurl with SSL support on Windows
Thanks Mr. https://stackoverflow.com/users/519376/vtellier
I have followed the following instructions with slight modifications and it worked fine for VS2017 with latest OpenSSL
In my case follow the curl README file was enough.
My configuration is the following:
Visual Studio 2017
Static library
Win64
curl version 7.57.0
OpenSSL 1.0.2
Compilation of libCurl
Download libcurl source there: https://curl.haxx.se/download.html
compress the file and go to the folder curl-7.57.0\projects
Open the README file and follow the instructions, this lead me to do the following:
Downloaded OpenSSL
Extract it and rename it to openssl, put it aside the curl folder, this is important as you'll open the VS project that expect
to find openssl there.
Install Perl
Execute the utility build-openssl.bat to perform the compilation of openSSL. With my settings this became the following:
\build-openssl.bat vc14 x64 release ....\openssl\
just runs .\build-openssl.bat -help to know more about the parameters.
After that you can see OpenSSL has been compiled as you got a new folder here: openssl\build\Win64
Open the Visual Studio project
curl-7.57.0\projects\Windows\VC14\curl-all.sln
Be sure to set the visual studio project to the build configuration
you need (LIB Release - LIB OpenSSL in my case)
Build all . The library is located at
curl-7.57.0\build\Win64\VC14\LIB Release - L

Error building tensorflow C++ shared library on windows

I am trying to build tensorflow as a standalone project and have been following this tutorial
http://www.stefanseibert.com/2017/10/tensorflow-as-dll-into-your-windows-c-project-with-gpu-support-and-cmake-v1-3/
but alternatively with cpu support
My environment setup versions
protobuf 3.6.1
tensorflow 1.10.0
tf.GIT_VERSION = b'v1.10.0-rc1-19-g656e7a2b34'
Here are the steps I used to generate the shared lib
Acquired source code from https://github.com/tensorflow/tensorflow.git
Have installed the dependencies since I do not use the python bindings, there is no need for SWIG, so I installed Git (version 2.15.1.windows.2) and cmake 3.11.1
I used the 64bit tools from Visual Studio 2015 since VS2015 is necessary to build the DLL. I should be able to open the “VS2015 x64 Native Tools Command Prompt”. This is needed so VS uses the 64 bit toolset.
Navigated in the commandline to the “tensorflow/contrib/cmake” subfolder of the source code and create a directory with “mkdir build”. Afterwards navigate to the fresh build folder with “cd build”.
Create a build solution: cmake .. -A x64 -DCMAKE_BUILD_TYPE=RelWithDebInfo -Dtensorflow_BUILD_CC_EXAMPLE=OFF -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF -Dtensorflow_BUILD_CC_TESTS=OFF -Dtensorflow_BUILD_PYTHON_TESTS=OFF -Dtensorflow_ENABLE_GPU=OFF -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX -Dtensorflow_BUILD_SHARED_LIB=ON
Everything went fine till this. To build the tensorflow.dll, I issued the following command: MSBuild /p:Configuration=RelWithDebInfo tensorflow.vcxproj
This throws an error: D:\work\tensorflow\tensorflow/core/lib/core/stringpiece.h(34): fatal error C1083: Cannot open include file: 'absl/strings/string_view.h': No such file or directory (
compiling source file D:\work\tensorflow\tensorflow\core\lib\core\coding.cc) [D:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_lib.vcxproj].
I fixed the above error with this: https://github.com/tensorflow/tensorflow/issues/22007#issuecomment-424553600.
Doing the above I ended up with this error: path.obj : error LNK2019: unresolved external symbol "void __cdecl absl::base_internal::ThrowStdOutOfRange(char const *)" (?ThrowStdOutOfRange#base_internal#absl##YA
XPEBD#Z) referenced in function "class std::basic_string,class std::allocator > __cdecl tensorflow::io::internal::JoinPathIm
I am not able to proceed further. Any workaround for this? Thanks!
lnk2019 error occurs when your directly you are using in your source code are not linked properly. Please add additional dependencies to your project.
Going to project properties
select C/C++ option
Add aditional dependencies
Go to Linker Option Below C/C++
Add additional Dependencies here.
It might be help full for you from getting out to LNK2019 problem
view this to understand LNK2019 error.
I met same issue, I think tensorflow new version doesn't support CMake, but we can solve the issues.
1. Seems the absl version in project folder is out dated, so I cloned the latest version of abseil-cpp from: https://github.com/abseil/abseil-cpp
2. Use cmake to build the abseil-cpp, it will be fast.
3. Add lib path to tensorflow dependency, the needed one will be D:\git\abseil-cpp\abseil-cpp\build\absl\base\Release\absl_absl_throw_delegate.lib
4. If you meet other linking error, you can find the function name in absl sources and find the library contain it.
Hope this can help you and people who may met this issue in future.

linking to boost with visual studio 2013

I'm trying to link to several boost libraries (the ones that need to be compiled) in visual studio 2013 and am having trouble doing so.
I've installed the boost files by runing from the command line
boostrap.bat
and
b2 --toolset=msvc-12.0 --build-type=complete architecture=x86 address-model=64 stage
so that the libraries are in C:\boost_1_56_0/stage/lib
In my project I go into configuration properties>c/c++>General>Additional include directories and include C:\boost_1_56_0 and include headers using for example
#include<boost/serialization/vector.hpp> among others
I then go to configuration properties>linker>additional library dependencies and include C:\boost_1_56_0\stage\lib
I am now aware that boost uses auto linking so I ensure that there are no attempts to directing link to the boost libraries in configuration properties>linker>input>additional dependencies
However I still get (many) linker errors of the following type:
error LNK2001: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_oarchive::end_preamble(void)" (?end_preamble#basic_oarchive#detail#archive#boost##QAEXXZ)
All the relevant questions I find concern misunderstandings of boost's auto linking facility, but I am now doing explicitly what I should be doing (to the best of my understanding). It is finding the the header files ok and the library files are where I am instructor the linker to look for them.
What might I be doing wrong?
There are tons of articles for linking boost in visual studio in stack overflow. One of them which I find minimal/complete is How to use Boost in Visual Studio 2010
I just run into similar question and share my idea with you.
You are probably compiling both 32bit and 64bit libs for boost. Thus I guess you maybe have two directories which contains the libs with the same names but built in different platform,like $(BOOST154_NEW_HOME)\lib_x64 and $(BOOST154_NEW_HOME)\lib_x86. You should have included both paths in your configuration properties>linker>additional library dependencies. Though boost are using auto_link to find out which lib you want to use, but it still confused about which lib under 32 bit or 64 bit need to be imported.
My suggestion is that you should include only 64bit boost libs directory in your configuration properties>linker>additional library dependencies.

vc++ vs2013 code with boost powered by nuget does not build

I am quite new to VC++ and Boost.
My problem is that I want to use Boost 1.56.0 in my VC++ Visual Studio 2013 project (so I use vc120).
I have installed Boost via NuGet (https://www.nuget.org/packages/boost/). Everything seems to be okay, but when I try to build my project it says:
Fatal error LNK1104: Cannot open file "libboost_thread-vc120-mt-gd-1_56.lib".
Do you know where exactly the problem is and how I can fix it?
I thought installing a package using NuGet will do the whole job to get things working on its own.
I know that the linker can't find the lib file (actually there was no build process at all). But I don't know how I can fix this issue.
I think it is not a good idea to manually compile Boost with VC120 and add the lib folder to the additional paths of the linker. Why should I use NuGet then?
Any help is welcome - I am trying and searching the internet for so many hours now and I couldn't fix the problem.
Thank you,
Stefan
As mentioned before, Boost Nuget can't contain all possible compiled libraries for all possible configuration and compiler versions. However, there are separete precompiled Nuget packages and also source packages. Here is a list of all 1.56.0 Boost Nuget packages https://getboost.codeplex.com/releases/view/126256
In your case, I would suggest to use precompiled boost_thread-vc120.1.56.0. Not 1.57 yet!
If you are lazy, you can also use boost-vc120.1.56.0 which depends on all precompiled Boost libraries for Visual Studio 2013.
It seems that the latest version of NuGet for boost doesn't include every lib and dll files package (source).
You should install boost_thread altogether.
BlueGo is a tool which builds Boost using Visual Studio 2010/12/13. You just have to start the application, select your configuration and hit the Build button- everything else works automatically.
It can be downloaded here: https://bitbucket.org/Vertexwahn/bluego
Since the NuGet packet of Boost does not contain the lib files anymore, because the package is getting to big, I have decided to build Boost by my own.
I followed this instructions: Build Boost for Visual Studio - also read the second post!
I saw it too late but maybe it is helpful for somebody else:
There are pre-build Boost installer!
Here you can download an installer, which will install Boost (of specific version) for 32/64 bit (depending on which file you choose). There are also already different versions (vc100, vc110, vc120) available.
The problem when you use NuGet is, that you have
Install the Boost package (to get the source files)
Install the lib files (see the link Marco A. provided)
This can be very cumbersome since not all libraries of Boost are available. E.g. the lib files of ASIO were missing. So if you need them you have to compile it again by your own. So you mess up your project with NuGet packages and self-compiled boost libs. If NuGet provides everything you need I would use the NuGet way.
Finally, as I said I need the ASIO lib and therefore I have finally compiled Boost by my own. It seemed so easy to just use a NuGet Package.
Thank you all for your help.

Compiling libpng and using it with netbeans and mingw

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.