I can't manage to link LibPNG statically to my VS2012(64bit) project.
I did the following:
Download libPNG source code for the latest version(1614).
Open the enclosed VisualStudio solution (projects/vstudio/vstudio.sln).
Select "Release Library" and set C/C++ -> Code Generation ->Runtime Library to "MDd" (same as in my project.
4.Compile static lib.
Then in the target project in the linker I specify in Additional Library directories the location of the lib and in the Input the name of the lib.
I also configured Zlib to be static as is proposed here.
Yet,when compiling I am getting :
error LNK2019: unresolved external symbol png_sig_cmp referenced in
function
For the very first function call to LibPNG API.
I have tried to tweak different properties of the lib but it doesn't work.Can it happen because the libPNG built as x86 lib and not x64?
So to sum up the comments, the solution here was to compile libPNG in 64bit mode.
You cannot compile 32bit assembly with 64bit assembly.
Related
I'm using Visual Studio 2017 and I'm trying to link to openssl 1.0.2 built by me as 64-bit Release static library as shown here. Actually it's my lib (also static) that is using openssl functions directly and executable is linking to this lib. I tried two approaches:
Put openssl's symbols into mylib.lib (using a tab in VS mylib's project properties called "Librarian")
Link to openssl (libeay32.lib, ssleay32.lib) and to my lib using Linker in executable's project
Both are resulting in linker errors like
error LNK2001: unresolved external symbol EVP_EncryptInit_ex
concerning mylib.lib library.
I looked into libeay32.lib (also into mylib.lib while using the Librarian approach), using dumpbin.exe provided by Visual Studio, and there's _EVP_EncryptInit_ex (note the _ at the beggining) symbol defined. So I'm wondering whether it is possible that openssl defines _EVP_EncryptInit_ex and the executable is trying to link to EVP_EncryptInit_ex? What could be the cause and solution? Also: How can I check for sure what symbols is exectuable trying to link to?
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.
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.
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.
I have built boost using the included tools and i ended up as expected with the stage/lib folder ! The lib folder contains several libraries with the following anming pattern:
libboost_*lib_name*_vc100_mt-gd-1_50.lib
libboost_*lib_name*_vc100_mt-1_50.lib
Though building a project with cl.exe i get a linker error 1104 for lib with the following pattern
libboost_*lib_name*_vc100_mt-s-1_50.lib
Any ideas ?? If on the other hand use visual studio 10 and set the stage/lib at my VC++ Direcotries - Library Direcotries, all work like a charm !
mt-s in lib name means your project is compiled with options to use multithreaded and statically linked C++ standard runtime library. Looks like your Boost build isn't configured to build such lib version, so it is missing.