title: visual studio c++ redis (msopentech port) client , hiredis
body: <p>I am new to c++, I decided to give it a try visual studio c++, boost, llvm(which already failed with boost 1.55 and visual studio 2013) and redis.</p>
  
  <p>This is a small pet project to parse raw data read from socket and cache into redis.</p>
  
  <p>When I tried to link to hiredis.lib I got lots of errors. </p>
  
  <p>I know I am doing something wrong but my trials turned into endless loop. I anybosy could guide about it , it would be much appreciated.</p>
  
  <p>Kind Regards.</p>
  
  <p>Errors:</p>
  
  <pre><code>1&gt;------ Build started: Project: example4, Configuration: Debug x64 ------
  1&gt;  Source.cpp
  1&gt;LIBCMTD.lib(dosmap.obj) : error LNK2005: _errno already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(dbgheap.obj) : error LNK2005: _CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(dbgheap.obj) : error LNK2005: _aligned_free already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(dbgheap.obj) : error LNK2005: _aligned_malloc already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc_dbg already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_wctype.obj) : error LNK2005: iswalnum already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_wctype.obj) : error LNK2005: iswalpha already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_wctype.obj) : error LNK2005: iswgraph already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_wctype.obj) : error LNK2005: iswspace already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(mlock.obj) : error LNK2005: _lock already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(mlock.obj) : error LNK2005: _unlock already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winapisupp.obj) : error LNK2005: __crtCaptureCurrentContext already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winapisupp.obj) : error LNK2005: __crtCapturePreviousContext already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winapisupp.obj) : error LNK2005: __crtSetUnhandledExceptionFilter already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winapisupp.obj) : error LNK2005: __crtTerminateProcess already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winapisupp.obj) : error LNK2005: __crtUnhandledException already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(tidtable.obj) : error LNK2005: _getptd already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(invarg.obj) : error LNK2005: _invalid_parameter already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(sprintf.obj) : error LNK2005: sprintf already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_file.obj) : error LNK2005: __iob_func already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_file.obj) : error LNK2005: _lock_file already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(_file.obj) : error LNK2005: _unlock_file already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0dat.obj) : error LNK2005: _amsg_exit already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0dat.obj) : error LNK2005: _cexit already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0dat.obj) : error LNK2005: _initterm_e already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0dat.obj) : error LNK2005: exit already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(errmode.obj) : error LNK2005: __set_app_type already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(winxfltr.obj) : error LNK2005: _XcptFilter already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(wsetloca.obj) : error LNK2005: _configthreadlocale already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(vsnprnc.obj) : error LNK2005: vsprintf_s already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(fflush.obj) : error LNK2005: fflush already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(crt0init.obj) : error LNK2005: __xi_a already defined in MSVCRTD.lib(cinitexe.obj)
  1&gt;LIBCMTD.lib(crt0init.obj) : error LNK2005: __xi_z already defined in MSVCRTD.lib(cinitexe.obj)
  1&gt;LIBCMTD.lib(crt0init.obj) : error LNK2005: __xc_a already defined in MSVCRTD.lib(cinitexe.obj)
  1&gt;LIBCMTD.lib(crt0init.obj) : error LNK2005: __xc_z already defined in MSVCRTD.lib(cinitexe.obj)
  1&gt;LIBCMTD.lib(dbgrptw.obj) : error LNK2005: _CrtDbgReportW already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;LIBCMTD.lib(printf.obj) : error LNK2005: printf already defined in MSVCRTD.lib(MSVCR120D.dll)
  1&gt;MSVCRTD.lib(MSVCR120D.dll) : error LNK2005: strcpy_s already defined in LIBCMTD.lib(strcpy_s.obj)
  1&gt;MSVCRTD.lib(MSVCR120D.dll) : error LNK2005: iswdigit already defined in LIBCMTD.lib(_wctype.obj)
  1&gt;LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
  1&gt;LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
  1&gt;hiredis.lib(hiredis.obj) : error LNK2019: unresolved external symbol strerror_r referenced in function __redisSetError
  1&gt;hiredis.lib(net.obj) : error LNK2001: unresolved external symbol strerror_r
  1&gt;hiredis.lib(hiredis.obj) : error LNK2001: unresolved external symbol fdapi_close
  1&gt;hiredis.lib(net.obj) : error LNK2001: unresolved external symbol fdapi_close
  1&gt;hiredis.lib(net.obj) : error LNK2001: unresolved external symbol fcntl
  1&gt;hiredis.lib(net.obj) : error LNK2001: unresolved external symbol poll
  1&gt;F:\SoftwareDevelopment\cplusplus\example4\x64\Debug\example4.exe : fatal error LNK1120: 4 unresolved externals
  ========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>Project File:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;ItemGroup Label="ProjectConfigurations"&gt;
      &lt;ProjectConfiguration Include="Debug|Win32"&gt;
        &lt;Configuration&gt;Debug&lt;/Configuration&gt;
        &lt;Platform&gt;Win32&lt;/Platform&gt;
      &lt;/ProjectConfiguration&gt;
      &lt;ProjectConfiguration Include="Debug|x64"&gt;
        &lt;Configuration&gt;Debug&lt;/Configuration&gt;
        &lt;Platform&gt;x64&lt;/Platform&gt;
      &lt;/ProjectConfiguration&gt;
      &lt;ProjectConfiguration Include="Release|Win32"&gt;
        &lt;Configuration&gt;Release&lt;/Configuration&gt;
        &lt;Platform&gt;Win32&lt;/Platform&gt;
      &lt;/ProjectConfiguration&gt;
      &lt;ProjectConfiguration Include="Release|x64"&gt;
        &lt;Configuration&gt;Release&lt;/Configuration&gt;
        &lt;Platform&gt;x64&lt;/Platform&gt;
      &lt;/ProjectConfiguration&gt;
    &lt;/ItemGroup&gt;
    &lt;PropertyGroup Label="Globals"&gt;
      &lt;ProjectGuid&gt;{FADCAD1B-D309-427E-8A12-2140E0CC1E3C}&lt;/ProjectGuid&gt;
      &lt;Keyword&gt;Win32Proj&lt;/Keyword&gt;
      &lt;RootNamespace&gt;example4&lt;/RootNamespace&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"&gt;
      &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;
      &lt;UseDebugLibraries&gt;true&lt;/UseDebugLibraries&gt;
      &lt;PlatformToolset&gt;v120&lt;/PlatformToolset&gt;
      &lt;CharacterSet&gt;Unicode&lt;/CharacterSet&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"&gt;
      &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;
      &lt;UseDebugLibraries&gt;true&lt;/UseDebugLibraries&gt;
      &lt;PlatformToolset&gt;v120&lt;/PlatformToolset&gt;
      &lt;CharacterSet&gt;Unicode&lt;/CharacterSet&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"&gt;
      &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;
      &lt;UseDebugLibraries&gt;false&lt;/UseDebugLibraries&gt;
      &lt;PlatformToolset&gt;v120&lt;/PlatformToolset&gt;
      &lt;WholeProgramOptimization&gt;true&lt;/WholeProgramOptimization&gt;
      &lt;CharacterSet&gt;Unicode&lt;/CharacterSet&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"&gt;
      &lt;ConfigurationType&gt;Application&lt;/ConfigurationType&gt;
      &lt;UseDebugLibraries&gt;false&lt;/UseDebugLibraries&gt;
      &lt;PlatformToolset&gt;v120&lt;/PlatformToolset&gt;
      &lt;WholeProgramOptimization&gt;true&lt;/WholeProgramOptimization&gt;
      &lt;CharacterSet&gt;Unicode&lt;/CharacterSet&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /&gt;
    &lt;ImportGroup Label="ExtensionSettings"&gt;
    &lt;/ImportGroup&gt;
    &lt;ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;
      &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
    &lt;/ImportGroup&gt;
    &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"&gt;
      &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
    &lt;/ImportGroup&gt;
    &lt;ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"&gt;
      &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
    &lt;/ImportGroup&gt;
    &lt;ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"&gt;
      &lt;Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /&gt;
    &lt;/ImportGroup&gt;
    &lt;PropertyGroup Label="UserMacros" /&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;
      &lt;LinkIncremental&gt;true&lt;/LinkIncremental&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"&gt;
      &lt;LinkIncremental&gt;true&lt;/LinkIncremental&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"&gt;
      &lt;LinkIncremental&gt;false&lt;/LinkIncremental&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"&gt;
      &lt;LinkIncremental&gt;false&lt;/LinkIncremental&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;
      &lt;ClCompile&gt;
        &lt;PrecompiledHeader&gt;NotUsing&lt;/PrecompiledHeader&gt;
        &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
        &lt;Optimization&gt;Disabled&lt;/Optimization&gt;
        &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
        &lt;AdditionalIncludeDirectories&gt;F:\Software\boost_1_55_0;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
        &lt;DebugInformationFormat&gt;None&lt;/DebugInformationFormat&gt;
        &lt;MultiProcessorCompilation&gt;true&lt;/MultiProcessorCompilation&gt;
        &lt;MinimalRebuild&gt;false&lt;/MinimalRebuild&gt;
      &lt;/ClCompile&gt;
      &lt;Link&gt;
        &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
        &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
        &lt;AdditionalLibraryDirectories&gt;F:\Software\boost_1_55_0\stage\lib;%(AdditionalLibraryDirectories)&lt;/AdditionalLibraryDirectories&gt;
        &lt;AdditionalDependencies&gt;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;
      &lt;/Link&gt;
      &lt;PostBuildEvent&gt;
        &lt;Command&gt;copy *.config "$(TargetDir)*.config"&lt;/Command&gt;
      &lt;/PostBuildEvent&gt;
    &lt;/ItemDefinitionGroup&gt;
    &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"&gt;
      &lt;ClCompile&gt;
        &lt;PrecompiledHeader&gt;NotUsing&lt;/PrecompiledHeader&gt;
        &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
        &lt;Optimization&gt;Disabled&lt;/Optimization&gt;
        &lt;PreprocessorDefinitions&gt;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
        &lt;AdditionalIncludeDirectories&gt;F:\Software\boost_1_55_0;F:\Software\redis\deps\hiredis;%(AdditionalIncludeDirectories)&lt;/AdditionalIncludeDirectories&gt;
        &lt;DebugInformationFormat&gt;None&lt;/DebugInformationFormat&gt;
        &lt;MultiProcessorCompilation&gt;true&lt;/MultiProcessorCompilation&gt;
        &lt;MinimalRebuild&gt;false&lt;/MinimalRebuild&gt;
      &lt;/ClCompile&gt;
      &lt;Link&gt;
        &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
        &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
        &lt;AdditionalLibraryDirectories&gt;F:\Software\boost_1_55_0\stage\lib;%(AdditionalLibraryDirectories)&lt;/AdditionalLibraryDirectories&gt;
        &lt;AdditionalDependencies&gt;%(AdditionalDependencies)&lt;/AdditionalDependencies&gt;
      &lt;/Link&gt;
      &lt;PostBuildEvent&gt;
        &lt;Command&gt;copy *.config "$(TargetDir)*.config"&lt;/Command&gt;
      &lt;/PostBuildEvent&gt;
    &lt;/ItemDefinitionGroup&gt;
    &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"&gt;
      &lt;ClCompile&gt;
        &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
        &lt;PrecompiledHeader&gt;
        &lt;/PrecompiledHeader&gt;
        &lt;Optimization&gt;MaxSpeed&lt;/Optimization&gt;
        &lt;FunctionLevelLinking&gt;true&lt;/FunctionLevelLinking&gt;
        &lt;IntrinsicFunctions&gt;true&lt;/IntrinsicFunctions&gt;
        &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;/ClCompile&gt;
      &lt;Link&gt;
        &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
        &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
        &lt;EnableCOMDATFolding&gt;true&lt;/EnableCOMDATFolding&gt;
        &lt;OptimizeReferences&gt;true&lt;/OptimizeReferences&gt;
      &lt;/Link&gt;
    &lt;/ItemDefinitionGroup&gt;
    &lt;ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"&gt;
      &lt;ClCompile&gt;
        &lt;WarningLevel&gt;Level3&lt;/WarningLevel&gt;
        &lt;PrecompiledHeader&gt;
        &lt;/PrecompiledHeader&gt;
        &lt;Optimization&gt;MaxSpeed&lt;/Optimization&gt;
        &lt;FunctionLevelLinking&gt;true&lt;/FunctionLevelLinking&gt;
        &lt;IntrinsicFunctions&gt;true&lt;/IntrinsicFunctions&gt;
        &lt;PreprocessorDefinitions&gt;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)&lt;/PreprocessorDefinitions&gt;
      &lt;/ClCompile&gt;
      &lt;Link&gt;
        &lt;SubSystem&gt;Console&lt;/SubSystem&gt;
        &lt;GenerateDebugInformation&gt;true&lt;/GenerateDebugInformation&gt;
        &lt;EnableCOMDATFolding&gt;true&lt;/EnableCOMDATFolding&gt;
        &lt;OptimizeReferences&gt;true&lt;/OptimizeReferences&gt;
      &lt;/Link&gt;
    &lt;/ItemDefinitionGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Include="app.config" /&gt;
      &lt;None Include="log.config"&gt;
        &lt;DeploymentContent&gt;true&lt;/DeploymentContent&gt;
        &lt;ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"&gt;
        &lt;/ExcludedFromBuild&gt;
        &lt;ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"&gt;
        &lt;/ExcludedFromBuild&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ClCompile Include="Source.cpp" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ProjectReference Include="..\..\..\..\Software\redis\msvs\hiredis\hiredis.vcxproj"&gt;
        &lt;Project&gt;{13e85053-54b3-487b-8ddb-3430b1c1b3bf}&lt;/Project&gt;
        &lt;Private&gt;true&lt;/Private&gt;
        &lt;ReferenceOutputAssembly&gt;true&lt;/ReferenceOutputAssembly&gt;
        &lt;CopyLocalSatelliteAssemblies&gt;false&lt;/CopyLocalSatelliteAssemblies&gt;
        &lt;LinkLibraryDependencies&gt;true&lt;/LinkLibraryDependencies&gt;
        &lt;UseLibraryDependencyInputs&gt;false&lt;/UseLibraryDependencyInputs&gt;
      &lt;/ProjectReference&gt;
    &lt;/ItemGroup&gt;
    &lt;Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /&gt;
    &lt;ImportGroup Label="ExtensionTargets" /&gt;
  &lt;/Project&gt;
  </code></pre>