I'm building OpenCV using Visual Studio 2010. I'm using static CRT linkage (/MTd) and then link opencv.lib to my project. But there is a problem in my project with linking zlib, which is required by OpenCV:
Error 1 error LNK2019: unresolved external symbol _gzputs referenced in function "void __cdecl icvPuts(struct CvFileStorage *,char const *)" (?icvPuts##YAXPAUCvFileStorage##PBD#Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 2 error LNK2019: unresolved external symbol _gzclose referenced in function "void __cdecl icvClose(struct CvFileStorage *)" (?icvClose##YAXPAUCvFileStorage###Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 3 error LNK2019: unresolved external symbol _gzopen referenced in function _cvOpenFileStorage o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 4 error LNK2019: unresolved external symbol _gzgets referenced in function "char * __cdecl icvGets(struct CvFileStorage *,char *,int)" (?icvGets##YAPADPAUCvFileStorage##PADH#Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 5 error LNK2019: unresolved external symbol _gzrewind referenced in function "void __cdecl icvRewind(struct CvFileStorage *)" (?icvRewind##YAXPAUCvFileStorage###Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 6 error LNK2019: unresolved external symbol _gzeof referenced in function "int __cdecl icvEof(struct CvFileStorage *)" (?icvEof##YAHPAUCvFileStorage###Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj) MyProject
Error 7 error LNK1120: 6 unresolved externals O:\products\MyProject\trunk\src\Debug\MyProject.dll 1 1 MyProject
Zlib is distributed with OpenCV and when I build it with Link Library Dependecies option checked, all works fine. However, when I uncheck this option and am trying to manually link zlib to my project, I receive these errors.
I ran dumpbin /symbols on opencv_core_vc10ds.lib looking for one of those symbols:
3BE 00000000 UNDEF notype () External | _gzputs
And the same for zlibd.lib:
042 00000000 SECT10 notype () External | _gzputs
So it seems like everything is ok: I have UNDEF entry in OpenCV library and defined external entry in zlib library. So why doesn't it build properly?
Update. Linker command line for my project:
/OUT:"O:\products\MyProject\trunk\src\Debug\MyProject.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:\SDK/MPFR/v3.1.0/MPFR/lib" /LIBPATH:"D:\SDK/MPIR/v2.5.1/MPIR/lib" /LIBPATH:"D:\SDK/JasPer/v1.900.1/JasPer/lib" /LIBPATH:"D:\SDK/CGAL/v3.9/lib" /LIBPATH:"D:\SDK/opencv/v2.3.1+IPPv7.0.205/opencv/lib" /LIBPATH:"D:\SDK/tinyxml/v2.0/tinyxml/lib" /LIBPATH:"D:\SDK/gtest/v1.6.0/gtest/lib" /LIBPATH:"D:\SDK\zlib\v125\zlib\lib" /LIBPATH:"D:\SDK\glew\v135\glew\lib" /LIBPATH:"D:\SDK\libpng\v141\libpng\lib" /LIBPATH:"D:\SDK\libtiff\v371\libtiff\lib" /LIBPATH:"D:\SDK\libgif\v40\libgif\lib" /LIBPATH:"D:\SDK\libjpeg\v6b\libjpeg\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\compiler\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\ipp\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\mkl\lib" /LIBPATH:"D:\SDK\directx\v9.29.1962\directx\Lib\x86" /LIBPATH:"D:\SDK\boost\v1.48\stage\lib\" /MANIFEST /ManifestFile:"Debug\MyProject.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"O:\products\MyProject\trunk\src\Debug\MyProject.pdb" /SUBSYSTEM:CONSOLE /PGD:"O:\products\MyProject\trunk\src\Debug\MyProject.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
Thanks to mevatron, problem was in library link order. There was another lib project MyLib in my solution which used zlib and was actually linked before zlib in MyProject.
Related
Here's the thing, guys:
I've got a trouble trying to make the entry point of my program not called main
Earlier, in Visual Studio 2012 that was pretty easy - I just used /ENTRY key of linker or the same setting of my project (Project->'project_name' properties...->Linker->Advanced->Entry Point) and it worked properly: say, I had a function like this:
int LetsRock
{
...
return 0;
}
And I needed, as described above, just set /ENTRY:LetsRock and it ran first.
But in Microsoft Visual Studio 2015 Enterprise Version 14.0.25123.00 Update 2 things turn out quite strange:
As soon as I redefine the entrypoint, compiler gives me the bunch of 11 errors (actually 10, 'cause 11th only says, that there are 10 errors):
Here they are, for those, who don't wanna open the picture:
1>------ Build started: Project: Tester, Configuration: Debug Win32 ------
1> Source.c
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT
1>MSVCRTD.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW
1>MSVCRTD.lib(_error_.obj) : error LNK2019: unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath##YAHPB_WPA_WI#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath##YAHPB_WPA_WI#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath##YAHPB_WPA_WI#Z)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPAUHINSTANCE__##XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPAUHINSTANCE__##XZ)
1>MSVCRTD.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll##YAPAUHINSTANCE__##XZ)
1>MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
1>C:\<path to my folder>\Tester\Debug\Tester.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It turns out even stranger - if I set entrypoint setting to main (of course, here I also rename my function in the source file), it still doesn't work. The same set of errors.
So, the question is:How do I properly redefine the entry point of C/C++ project in Visual Studio 2015?
If this is impossible, why haven't they, finally, removed this setting?
Ok, as Hans Passant advised, I just added more .lib dependencies: vcruntimed.lib and ucrtd.lib, and it worked fine. It is compiled in Release configuration without those libs, but in this way it may not wok correctly - In my case, the program
#include <stdio.h>
int LetsRock()
{
getchar();
return 0;
}
didn't run, saying error LNK2001: unresolved external symbol __imp__getchar
I have a running project in Visual Studio 2010 using OpenCV 2.49 and Point Cloud Library 1.6 . I am trying to make a standalone executable so I don´t need to install OpenCV and PCL in other computers to make it run.
OpenCV and PCL were installed using the precompiled binaries, and PCL also included boost (1.49) and vtk (5.8) libraries, among others.
For making the static build, I changed the Runtime Library in VS to /MT. Then, some Boost static libraries were missing, so I installed boost again (version 1.56, I believe I needed the libs with the 's').
Then I had errors like:
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
so I added msvcrt.lib, msvcprt.lib to the section "Ignore Specific Defaul Libraries".
Now I have errors like:
1>vtkCommon.lib(vtkVoidArray.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(void const *)" (__imp_??6?$basic_ostream#DU?$char_traits#D#std###std##QAEAAV01#PBX#Z)
1>vtkCommon.lib(vtkVariantArray.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(void const *)" (__imp_??6?$basic_ostream#DU?$char_traits#D#std###std##QAEAAV01#PBX#Z)
1>vtkCommon.lib(vtkTimerLog.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>vtkCommon.lib(vtkMath.obj) : error LNK2001: unresolved external symbol __imp__modf
1>vtksys.lib(SystemTools.obj) : error LNK2001: unresolved external symbol __imp___utime64
1>OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp__unlink
The vtk library is included exactly the same way as in the non-static release build. And, if I understood it correctly, .lib is an extension for a static libray.
What am I doing wrong?
EDIT: I tried using CMake, but I am getting the same kind of errors (There are a lot more):
2>vtksys.lib(SystemTools.obj) : error LNK2019: unresolved external symbol __imp___time64 referenced in function _time
2>vtkCommon.lib(vtkVariant.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::operator>>(short &)" (__imp_??5?$basic_istream#DU?$char_traits#D#std###std##QAEAAV01#AAF#Z) referenced in function "short __cdecl vtkVariantStringToNumeric<short>(class vtkStdString,bool *,short *)" (??$vtkVariantStringToNumeric#F##YAFVvtkStdString##PA_NPAF#Z)
This is my CMakeList.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(3DVisualizerCM)
set(BUILD_SHARED_LIBS OFF)
SET(CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:msvcrt.lib
/NODEFAULTLIB:msvcprt.lib")
find_package(PCL 1.4 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS} )
link_directories(${PCL_LIBRARY_DIRS} )
add_definitions(${PCL_DEFINITIONS} )
add_executable (3D_v4
3D_v4.cpp
C3DVisualizer.cpp
C3DVisualizerMultiple.cpp
C3DVisualizerSingle.cpp
CCameraParameters.cpp
CImageTrack.cpp
CImg.cpp
CImgMultiple.cpp
CImgSingle.cpp
helpers.cpp
)
target_link_libraries (3D_v4 ${PCL_LIBRARIES} ${OpenCV_LIBS})
The precompiled vtk libraries you are using from PCL must have been compiled using /MD flag (Multithreaded DLL) in Visual Studio. You need to recompile them using the /MT flag (Multithreaded static link).
I'm working to get libjingle working on windows7 using visual studio. I followed GYP methodology to build lib jingle and got libs after executing the libjingle.sln file.
Now, when I'm trying to run pcp_main.cc file, I got slashed with linker errors, after some work around, I was left with 5 linker errors. Can someone help me how to resolve those errors?
Error 5 error LNK1120: 4 unresolved externals C:\Users\username\documents\visual studio
2012\Projects\PCPTest\Debug\PCPTest.exe Error 3 error LNK2001:
unresolved external symbol "protected: virtual bool __thiscall
buzz::JingleInfoTask::HandleStanza(class buzz::XmlElement const *)"
(?HandleStanza#JingleInfoTask#buzz##MAE_NPBVXmlElement#2##Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 1 error LNK2001: unresolved external symbol "public: virtual int
__thiscall buzz::JingleInfoTask::ProcessStart(void)" (?ProcessStart#JingleInfoTask#buzz##UAEHXZ) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 2 error LNK2019: unresolved external symbol "public: void
__thiscall buzz::JingleInfoTask::RefreshJingleInfoNow(void)" (?RefreshJingleInfoNow#JingleInfoTask#buzz##QAEXXZ) referenced in
function "public: void __thiscall
AutoPortAllocator::SetXmppClient(class buzz::XmppClient *)"
(?SetXmppClient#AutoPortAllocator##QAEXPAVXmppClient#buzz###Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 4 error LNK2019: unresolved external symbol
_imp_InternetQueryOptionW#16 referenced in function "bool __cdecl talk_base::GetIeLanProxySettings(char const *,struct
talk_base::ProxyInfo *)"
(?GetIeLanProxySettings#talk_base##YA_NPBDPAUProxyInfo#1##Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\libjingle.lib(proxydetect.obj)
My include folder is pointing to
C:\Users\username\Desktop\libjingle\trunk\testing
C:\Users\username\Desktop\libjingle\trunk\
and lib folder to
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib
Additional dependencies have absolute paths of all the available libs.
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\audio_processing_sse2.lib
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\bitrate_controller.lib
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\CNG.lib
...
...
...
The source codeI'm using is present here.
http://pastebin.com/GATFYWnW
Got the answer!
The Error 4 can be removed by adding the following line
#pragma comment(lib, "Wininet.lib")
The remaining errors correspond to the jingleInfoTask.cc and JingleInfotask.h files. Its a bit surprise to see that the solution file (libjingle.sln) doesnt have these files when it built libraries. The work around would be to add the jingleinfotask.cc and jingleinfotask.h files into xmpp folder and re-build the libjingle.sln file.
This will produce the jingleinfotask.obj and required lib files. Make sure you point the generated lib file in the additional dependencies section in linker section of project properties.
I have been trying to upgrade to wxWidgets 2.9.4 over my old 2.8.12 and have run into problems. I compiled it without errors from the command line but when I try to use them in the program that worked just fine under the previous version I get unresolved externals. I cut it down to just a bare frame and TextCtrl object and it still does this (it's basically identical to one of the sample codes at the moment).
I tried the following commands to build the static libraries:
nmake -f makefile.vc SHARED=0 BUILD=release + nmake -f makefile.vc SHARED=0 BUILD=debug
nmake -f makefile.vc SHARED=0 MONOLITHIC=0 BUILD=release + nmake -f makefile.vc SHARED=0 MONOLITHIC=0 BUILD=debug
nmake -f makefile.vc SHARED=0 BUILD=release UNICODE=0 + nmake -f makefile.vc SHARED=0 BUILD=debug UNICODE=0
nmake -f makefile.vc SHARED=0 BUILD=release UNICODE=0 MONOLITHIC=0 + nmake -f makefile.vc SHARED=0 BUILD=debug UNICODE=0 MONOLITHIC=0
Note that I tried using them with both the recommended unicode and no longer supported non-unicode (changed the project properties in Configuration Properties->General accordingly). Also, I used multi-threaded DLL /MD and /MDd linking as recommended by the wxWidgets manual.
Edit: Tried using \MT and \MTd as well, same effect.
From all of the above I get the same linker errors listed below when compiling my application. Please advise me what to do because I have ran out of ideas...
Additionally, as a final resort I built the whole thing using the converted MSVS project from the ../build/msw folder but it gave me the same results.
Debug compile
1>hworld.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall wxApp::Initialize(int &,unsigned short * *)" (?Initialize#wxApp##UAE_NAAHPAPAG#Z)
1>hworld.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsoleBase::OnAssertFailure(unsigned short const *,int,unsigned short const *,unsigned short const *,unsigned short const *)" (?OnAssertFailure#wxAppConsoleBase##UAEXPBGH000#Z)
1>hworld.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall wxAppConsoleBase::OnAssert(unsigned short const *,int,unsigned short const *,unsigned short const *)" (?OnAssert#wxAppConsoleBase##UAEXPBGH00#Z)
1>hworld.obj : error LNK2001: unresolved external symbol "unsigned short const * const wxEmptyString" (?wxEmptyString##3PBGB)
1>hworld.obj : error LNK2019: unresolved external symbol "private: static struct wxString::SubstrBufFromType<class wxScopedCharTypeBuffer<unsigned short> > __cdecl wxString::ConvertStr(char const *,unsigned int,class wxMBConv const &)" (?ConvertStr#wxString##CA?AU?$SubstrBufFromType#V?$wxScopedCharTypeBuffer#G###1#PBDIABVwxMBConv###Z) referenced in function "private: static class wxScopedCharTypeBuffer<unsigned short> __cdecl wxString::ImplStr(char const *,class wxMBConv const &)" (?ImplStr#wxString##CA?AV?$wxScopedCharTypeBuffer#G##PBDABVwxMBConv###Z)
1>hworld.obj : error LNK2019: unresolved external symbol "void __cdecl wxOnAssert(char const *,int,char const *,char const *,unsigned short const *)" (?wxOnAssert##YAXPBDH00PBG#Z) referenced in function "public: void __thiscall wxControlContainerBase::SetContainerWindow(class wxWindow *)" (?SetContainerWindow#wxControlContainerBase##QAEXPAVwxWindow###Z)
1>wxpngd.lib(wxpng_pngread.obj) : error LNK2019: unresolved external symbol _inflateInit_ referenced in function _png_create_read_struct_2
1>wxpngd.lib(wxpng_pngread.obj) : error LNK2019: unresolved external symbol _inflate referenced in function _png_read_row
1>wxpngd.lib(wxpng_pngrutil.obj) : error LNK2001: unresolved external symbol _inflate
1>wxpngd.lib(wxpng_pngread.obj) : error LNK2019: unresolved external symbol _inflateEnd referenced in function _png_read_destroy
1>wxpngd.lib(wxpng_png.obj) : error LNK2019: unresolved external symbol _crc32 referenced in function _png_reset_crc
1>wxpngd.lib(wxpng_png.obj) : error LNK2019: unresolved external symbol _inflateReset referenced in function _png_reset_zstream
1>wxpngd.lib(wxpng_pngrutil.obj) : error LNK2001: unresolved external symbol _inflateReset
1>wxpngd.lib(wxpng_pngwrite.obj) : error LNK2019: unresolved external symbol _deflate referenced in function _png_write_flush
1>wxpngd.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol _deflate
1>wxpngd.lib(wxpng_pngwrite.obj) : error LNK2019: unresolved external symbol _deflateEnd referenced in function _png_write_destroy
1>wxpngd.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol _deflateEnd
1>wxpngd.lib(wxpng_pngwutil.obj) : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function _png_zlib_claim
1>wxpngd.lib(wxpng_pngwutil.obj) : error LNK2019: unresolved external symbol _deflateReset referenced in function _png_zlib_release
Release compile
1>wxpng.lib(wxpng_png.obj) : error LNK2001: unresolved external symbol _crc32
1>wxpng.lib(wxpng_png.obj) : error LNK2001: unresolved external symbol _inflateReset
1>wxpng.lib(wxpng_pngrutil.obj) : error LNK2001: unresolved external symbol _inflateReset
1>wxpng.lib(wxpng_pngread.obj) : error LNK2001: unresolved external symbol inflateInit
1>wxpng.lib(wxpng_pngread.obj) : error LNK2001: unresolved external symbol _inflate
1>wxpng.lib(wxpng_pngrutil.obj) : error LNK2001: unresolved external symbol _inflate
1>wxpng.lib(wxpng_pngread.obj) : error LNK2001: unresolved external symbol _inflateEnd
1>wxpng.lib(wxpng_pngwrite.obj) : error LNK2001: unresolved external symbol _deflate
1>wxpng.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol _deflate
1>wxpng.lib(wxpng_pngwrite.obj) : error LNK2001: unresolved external symbol _deflateEnd
1>wxpng.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol _deflateEnd
1>wxpng.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol deflateInit2
1>wxpng.lib(wxpng_pngwutil.obj) : error LNK2001: unresolved external symbol _deflateReset
1>MSVCRT.lib(crtexe.obj) : error LNK2001: unresolved external symbol _main
All errors coming from libpng are due to not linking with wxzlib[d].lib, simply add it to the list of libraries in your project. Or use the recommended way to build wxWidgets projects with MSVC and use auto-linking by prepending -I$(WXWIN)/include/msvc to your compiler header files search path.
The rest of the errors (which you only get in debug build which is suspicious on its own) are due to a mismatch between ANSI and Unicode builds. I don't know which version do you use finally as you seem to have built all of them at one moment or the other but if you use the default build, then you need to have _UNICODE and/or UNICODE defined in your project options.
Finally, to avoid such build mismatches in the future, either do nmake -f makefile.vc clean or use different build directories by using unique COMPILER_PREFIX for each build in the future. This is really not rocket science, you just need to avoid confusing yourself by doing too many things at once. Good luck!
Go to your project's settings and change General -> Character Set property accordingly. If you compiled the wx libs with UNICODE=0 (however recommended value is 1) then you need to use Multi-Byte Character set. If compiled ith UNICODE=1 then set that property to Unicode
As for runtime libs, if you compiled with SHARED=0 then in your project settings you will need to use C++ -> Code Generation -> Runtime Libraries property with 'Multi-Threaded Debug' and 'Multi-Threaded' for Debug and Release build accordingly.
The easiest way is to build wxWidgets libs from Visual Studio (there is a build/msw folder which contains solution file for VS2010) and in your project set the same properties as wx libs projects have.
I had this problem as well. I solved it by changing the setting in:
C/C++ | Language | Treat WChar_t as built in type
to Yes.
I'm trying to compile the Boost 1.47 ASIO SSL server and client examples. I can sucessfully incorporate Boost into my project, but I cannot incorporate OpenSSL. When I try to add it I get the errors:
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_reason_error_string referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall boost::asio::error::detail::ssl_category::message(int)const " (?message#ssl_category#detail#error#asio#boost##UBE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_id_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_library_init referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ENGINE_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CONF_modules_unload referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_cleanup_all_ex_data referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _EVP_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_remove_state referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_free_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>C:\Users\Epicism\Documents\Visual Studio 2010\Projects\SSLServer\Debug\SSLServer.exe : fatal error LNK1120: 12 unresolved externals
1>
1>Build FAILED.
I have tried adding the directory C:\OpenSSL-Win32\lib\, C:\OpenSSL-Win32\lib\VC\, C:\OpenSSL-Win32\lib\VC\static, C:\OpenSSL-Win32\bin, C:\OpenSSL-Win32\include to Project->General Properties->Linker->Additional Library Directories using the openssl pre-compiled libraries (http://www.openssl.org/related/binaries.html). I have also tried compiling OpenSSL myself with the same errors. I'm really at a loss, I have tried everything I have searched Google about a thousand times, tried IRC, every combination of directories I can think of...
My setup is:
Windows 7 64-bit
Windows Visual Studio 2010 64 bit
Boost 1.47
OpenSSL 1.0.0E and G
C/C++ Additional Include Directories: C:\Program Files (x86)\boost\boost_1_47;C:\openssl\include\;C:\OpenSSL-Win32\lib;%(AdditionalIncludeDirectories)
Project->General Properties->Linker->Additional Library Directories: C:\Program Files (x86)\boost\boost_1_47\lib;C:\openssl\lib;C:\openssl;%(AdditionalLibraryDirectories)
- I've tried adding every directory to this property as well....
Right now I'm just trying to compile the following in a VS C++ console project:
// SSLServer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Thanks in advance.
Looks like you're using the 32-bit version of OpenSSL on a 64-bit machine.
Try downloading the 64-bit version (Win64 OpenSSL v1.0.0g) from http://www.slproweb.com/products/Win32OpenSSL.html
After that's installed (if you use default paths), you should have a C:\OpenSSL-Win64 folder.
You should add:
C:\OpenSSL-Win64\include to your Additional Include Directories
C:\OpenSSL-Win64\lib\VC\static or C:\OpenSSL-Win64\lib\VC to your Additional Library Directories depending on whether you want the static libs or the dlls respectively
libeay32<XXX>.lib and ssleay32<XXX>.lib to Additional Dependencies where <XXX> matches whatever setting you have for [C/C++]->[Code Generation]->[Runtime Library]
I managed to get your little program above to build by linking with the 32-bit version of the Boost library along with the 32-bit version of OpenSSL. You will also need the 32-bit version of the redistributables as well. The bug is present in Boost version 1.51 and 1.52, which are the only versions I tested.
I believe there is a bug in the 64-bit version of the ASIO library. Although, it is possible that it is some sort of configuration problem that has affected many others. I have submitted a Boost bug report about the issue.
I met with the similar issue(VS2010), solved methods:
1)Properties->C/C++ ->general->additional include Directories: yourpath\boost_1_58_0\boost_1_58_0 (I use 1.58.0 version)
2)Properties->Linker ->general->additional library directories:
yourpath\boost_1_58_0\boost_1_58_0\stage\lib
3)Properties->Linker ->Input ->additional Dependencies:
libeay32.lib
ssleay32.lib
These two .lib files are copied from openssl install directory.