Windows VS Linker error

setup

#1

Hi Community,

I am trying set up C client on Visual Studio without downloading via Nuget.

I downloaded the include files, and the lib/dll files from the repository.

One link error happened during link time.

link error:

LNK2001 unresolved external symbol g_as_log

Help is appreciated.


#2

The Nuget download automatically performs the extra configuration steps necessary to compile/link/run applications that use the Aerospike C client library. This configuration is located in “vs/aerospike-client-c-{eventlib}.targets”.

If not downloading via Nuget, you need to manually perform this configuration. For example, here is “vs/aerospike-client-c-libuv.targets”:

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemDefinitionGroup>
    <ClCompile>
	  <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4996</DisableSpecificWarnings>
      <PreprocessorDefinitions>AS_USE_LIBUV;USING_UV_SHARED;AS_SHARED_IMPORT;_CRT_SECURE_NO_DEPRECATE;_TIMESPEC_DEFINED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(UseDebugLibraries)' == 'true'">
    <Link>
      <AdditionalLibraryDirectories>$(MSBuildThisFileDirectory)lib\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
	  <AdditionalDependencies>aerospike.lib;libuv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(UseDebugLibraries)' == 'false'">
    <Link>
      <AdditionalLibraryDirectories>$(MSBuildThisFileDirectory)lib\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
	  <AdditionalDependencies>aerospike.lib;libuv.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <Target Name="AfterBuild">
    <ItemGroup Condition="'$(UseDebugLibraries)' == 'true'">
      <AerospikePackageFiles Include="$(MSBuildThisFileDirectory)lib\x64\Debug\*.dll"/>
      <AerospikePackageFiles Include="$(MSBuildThisFileDirectory)lib\x64\Debug\*.pdb"/>
    </ItemGroup>
    <ItemGroup Condition="'$(UseDebugLibraries)' == 'false'">
      <AerospikePackageFiles Include="$(MSBuildThisFileDirectory)lib\x64\Release\*.dll"/>
    </ItemGroup>
    <Copy SourceFiles="@(AerospikePackageFiles)" DestinationFolder="$(OutputPath)"></Copy> 
  </Target>
</Project>

For Aerospike/libuv, you need to perform this configuration in your application project.

  1. Define these macros: AS_USE_LIBUV;USING_UV_SHARED;AS_SHARED_IMPORT;_CRT_SECURE_NO_DEPRECATE;_TIMESPEC_DEFINED

  2. Disable 4996 warning.

  3. Use aerospike.lib and libuv.lib and define directory where these libraries exists.


#3

Thanks Brian, I did not declare the macro AS_SHARED_IMPORT for c-libevent.