Static build with PCL and OpenCV in Visual Studio 2010 - visual-studio-2010

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

Related

wxWidgets 2.9.4 built under Visual C++ Express 2010 gives unresolved external errors

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.

Linking errors when building against Boost Unit Test Framework

I am trying to use Boost Unit Test Framework by building a stand alone library as detailed here:
http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/compilation.html
So I created a VC library project containing the mentioned files and build it and it was successful. Then I created a test project and referenced the library project I just created, but when I tried to build it, I got the following linking errors:
1>Type.obj : error LNK2019: unresolved external symbol "bool __cdecl boost::test_tools::tt_detail::check_impl(class boost::test_tools::predicate_result const &,class boost::unit_test::lazy_ostream const &,class boost::unit_test::basic_cstring<char const >,unsigned __int64,enum boost::test_tools::tt_detail::tool_level,enum boost::test_tools::tt_detail::check_type,unsigned __int64,...)" (?check_impl#tt_detail#test_tools#boost##YA_NAEBVpredicate_result#23#AEBVlazy_ostream#unit_test#3#V?$basic_cstring#$$CBD#63#_KW4tool_level#123#W4check_type#123#3ZZ) referenced in function "public: void __cdecl test1::test_method(void)" (?test_method#test1##QEAAXXZ)
1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::break_memory_alloc(long)" (?break_memory_alloc#debug#boost##YAXJ#Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init#framework#unit_test#boost##YAXP6APEAVtest_suite#23#HQEAPEAD#ZH0#Z)
1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::detect_memory_leaks(bool)" (?detect_memory_leaks#debug#boost##YAX_N#Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init#framework#unit_test#boost##YAXP6APEAVtest_suite#23#HQEAPEAD#ZH0#Z)
1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::attach_debugger(bool)" (?attach_debugger#debug#boost##YA_N_N#Z) referenced in function "public: int __cdecl boost::detail::system_signal_exception::operator()(unsigned int,struct _EXCEPTION_POINTERS *)" (??Rsystem_signal_exception#detail#boost##QEAAHIPEAU_EXCEPTION_POINTERS###Z)
1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::under_debugger(void)" (?under_debugger#debug#boost##YA_NXZ) referenced in function "public: int __cdecl boost::execution_monitor::execute(class boost::unit_test::callback0<int> const &)" (?execute#execution_monitor#boost##QEAAHAEBV?$callback0#H#unit_test#2##Z)
1>BoostUnitTestFramework.lib(unit_test_main.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite##YAPEAVtest_suite#unit_test#boost##HQEAPEAD#Z) referenced in function main
1>C:\Users\Rafid\Workspace\MyPhysics\Builds\VC10\Tests\Debug\Tests.exe : fatal error LNK1120: 6 unresolved externals
They seem to be mainly caused by Boost debug library, but I can't see a reason why I should get linking errors putting in mind that Boost debug library only need to be included as header files, rather than linking against as a library!
Any ideas?!
OK, I figured out what the problem is. Apparently, the list of files mentioned in Boost's website misses the following files:
debug.cpp
test_main.cpp
test_tools.cpp
Once I added those files to my project, the test project compiled and run successfully!
UPDATE: Just wanted to mention that I actually built against Boost 1.51, so it could be that the documentation is a bit old, because I can see that in the page, they are linking the files to Boost 1.35!
For compile unit-tests of boots 1.57 on windows,
I use #Rafid answer,
For me it was add this files to projects:
test_tools.cpp
unit_test_main.cpp
framework.cpp
That locate in BOOST_DIR/libs/test/src

VS2010 Unresolved External Symbol boost::asio::detail::winsock_init_base::throw_on_error when linking boost-system with a project using libtorrent

I'm trying to build a small command line BitTorrent client using Rasterbar's libtorrent, which depends on Boost. I've built both the Boost libraries and the libtorrent library using their respective directions, but when I try to build my project I get the following linking errors
1>------ Build started: Project: MiniBT, Configuration: Debug Win32 ------
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init#$01$0A##detail#asio#boost##QAE#_N#Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init#$01$0A##detail#asio#boost##QAE#_N#Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) referenced in function "void __cdecl boost::asio::error::`dynamic initializer for 'misc_category''(void)" (??__Emisc_category#error#asio#boost##YAXXZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) referenced in function "public: __thiscall boost::asio::detail::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>(void)" (??0?$win_tss_ptr#Vcontext#?$call_stack#Vwin_iocp_io_service#detail#asio#boost##E#detail#asio#boost###detail#asio#boost##QAE#XZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::~winsock_init<2,0>(void)" (??1?$winsock_init#$01$0A##detail#asio#boost##QAE#XZ)
It seems to indicate that the asio::detail namespace didn't get included in the boost-system library as it is only those 5 symbols that it seems to have a problem with and it is linking to the boost-system library just fine otherwise. I'm trying to build a 32-bit application on a 64-bit system, but everything I've checked seems to be correctly configured for this.
I know I'm missing something, but I can't seem to figure out what. Does anyone have any suggestions?
With BOOST_ASIO_SEPARATE_COMPILATION defined, in addition to #include "boost/asio/ssl/impl/src.hpp", you must also #include "boost/asio/impl/src.hpp" in one of your cpp files.

Boost SSL with Visual Studio 2010 and OpenSSL

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.

Build problem in Visual Studio 2010

I use CS106 library in the university.After changing Visual Studio 2008 with Visual Studio 2010, I have problems with building new projects or the old ones.I think that new Visual studio is not compatible with CS106 library.Can anyone tell how to fix this problem?
This is the output:
1>------ Build started: Project: Blank, Configuration: Debug Win32 ------
1>Build started 3/15/2011 2:03:21 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Blank.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ) referenced in function "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (?assign#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QAEAAV12#ABV12#II#Z)
1>CS106CPPLib.lib(genlib.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(init.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(pcgraphics.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ) referenced in function "protected: bool __thiscall std::basic_string,class std::allocator >::_Grow(unsigned int,bool)" (?_Grow#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##IAE_NI_N#Z)
1>CS106CPPLib.lib(genlib.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(init.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(pcgraphics.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register#facet#locale#std##CAXPAV123##Z) referenced in function "public: void __thiscall std::locale::facet::_Register(void)" (?_Register#facet#locale#std##QAEXXZ)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register#facet#locale#std##CAXPAV123##Z)
1>CS106CPPLib.lib(simpio.obj) : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF#std##3JB)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF#std##3JB)
1>Debug\Blank.exe : fatal error LNK1120: 4 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.97
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here is the solution:
http://melbsdailydigest.blogspot.com/
1.) Download one of the latest projects from the Stanford CS106B Website:
CS106B Assignment 1
2.) Unzip the project and find its subdirectory \CS106. This is the folder that contains all the library (CS106CPPLib.lib) and header files for the CS106 program.
3.) Copy this folder as a subdirectory to one of your assignment folders (ex. C:\Assignment1\CS106.
4.) Startup Visual Studio2008 and click File->New->Project… When given the choice choose to create a new Console program.
5.) You’ll then be presented with a new project with multiple files including stdafx.h, stdafx.cpp and similarly named files for whatever you named your project when prompted earlier. DELETE/ REMOVE all these files from the project.
6.) Right click the Source File Folder and choose Add->Existing Item… Choose the first assignment file (Assign1warmup.cpp).
7.) If you compile at this point you’ll realize that it’s still looking for the stdafx.h precompiled header. Let’s fix that. Go to Project->Assignment1 Properties… (or whatever your project might be named). Go to the option in the “tree” menu for Configuration Properties->C/C++->Pre-Compiled Headers . Under the option for Create/Use Precompiled header, choose the drop down option for Not Using Precompiled headers.
8.) While you’re in this section, take the time now to also select the location for the header files for this project. Under the Configuration Properties->C/C++->General section choose the Additional Include Directories option and use the … to browse and select the CS106 folder that you copied to your project folder earlier.
9.) One last thing you should change here is in the Configuration Properties->C/C++->Code Generation section. Change the default (which I believe is for a Multi-Threaded Debug .DLL) to just Multi-Threaded Debug (or just Multi-Threaded if you are doing your release build).
10.) Lastly, we’ll need to let the linker know where to find the CS106 library file. To do that you’ll need to make 2 additional settings. One is in the Configuration Properties->Linker->General section where you can select the location of your additional library files in the section titled appropriately enough – “Additional Library Directories”. You’ll also need to add your library to the project through the “Additional Dependencies” section which is under Configuration Properties->Linker->Input. Just type in CS106CPPLIB.lib.
Note: I found that there seems to be some difference in the menus you get and the settings that get saved depending on what your selection is at the moment in the solution Explorer Window. I originally made all my changes while I was selecting the actual source file, but there were no linker menus at that point. I had to move up to the Source File Folder level to get additional menus where I could set my linker options. Also important to note is that if you make your settings at the lower level (ie. Cpp file) they seem to supersede whatever is set in the level above it.
At this point the project should correctly build with the selection of the Build->Rebuild Solution command.
Happy programming!
The source code would help to fix this. But....did you add #include <string> at the top of the file producing the errors?

Resources