Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ritwik_D_1
Beginner
71 Views

Linker error for cache_aligned_allocator

Hi,

I am using tbb::cache_aligned_allocator in my C++ project in Visual Studio 2013 but I am getting a bunch of linker errors while building the project. I have added all the libraries

    irml\irml_debug.lib;
    tbb_debug.lib;
    tbb_preview_debug.lib;
    tbbmalloc_debug.lib;
    tbbproxy_debug.lib;
    tbbmalloc_proxy_debug.lib;

 in the additional library options.

Linker errors:

error LNK2019: unresolved external symbol "void * __cdecl tbb::internal::NFS_Allocate(unsigned int,unsigned int,void *)" (?NFS_Allocate@internal@tbb@@YAPAXIIPAX@Z) referenced in function "public: unsigned char * __thiscall tbb:
:cache_aligned_allocator<unsigned char>::allocate(unsigned int,void const *)" (?allocate@?$cache_aligned_allocator@E@tbb@@QAEPAEIPBX@Z)

error LNK2019: unresolved external symbol "void __cdecl tbb::internal::NFS_Free(void *)" (?NFS_Free@internal@tbb@@YAXPAX@Z) referenced in function "public: void __thiscall tbb::cache_aligned_allocator<unsigned char>::deallocate
(unsigned char *,unsigned int)" (?deallocate@?$cache_aligned_allocator@E@tbb@@QAEXPAEI@Z)

fatal error LNK1120: 2 unresolved externals

 

0 Kudos
8 Replies
Alexei_K_Intel
Employee
71 Views

Hi,

I am not sure but it looks like that the application is built for Win32 (ia32) but the libraries are taken from intel64 subdirectory.

P.S. you do not need to link to TBB-related libraries directly on Windows. You need either to source "tbbvars.bat vs2013 ia32" ("tbbvars.bat vs2013 intel64") or add the directory with required libraries into Visual Studio library directory config. If you still want to link directly, link to tbb(_debug).lib and tbbmalloc(_debug).lib

P.P.S. I do not recommend to mix linking to preview and non-preview versions of libraries. It may lead to unpredictable results.

Regards, Alex

Ritwik_D_1
Beginner
71 Views

I have removed the preview libs and just have tbb.lib and tbbmalloc.lib (and their debug versions) but still getting same error.

<Link>
  <AdditionalDependencies Condition="'$(Configuration)'=='Debug'">
   tbb_debug.lib;
   tbbmalloc_debug.lib;
   %(AdditionalDependencies)
  </AdditionalDependencies>
  <AdditionalDependencies Condition="'$(Configuration)'=='Release'">
   tbb.lib;
   tbbmalloc.lib;
   %(AdditionalDependencies)
  </AdditionalDependencies>
  <AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Root)\ext\tbb\lib\x86\debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  <AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Root)\ext\tbb\lib\amd64\debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  <AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Root)\ext\tbb\lib\x86\retail;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  <AdditionalLibraryDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Root)\ext\tbb\lib\amd64\retail;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
 </Link>

What makes you think the libs are picked from the intel64 subdirectory?

 

Alexei_K_Intel
Employee
71 Views

The configuration looks reasonable. So I can suppose only quite obvious things but I need to ask about them. Have you check the library directories? Are they achievable and the libraries exist and have the correct architecture? Is $(Root) variable exported and visible in Visual Studio?

As for 64-bit version of the library, it was just a supposition because the NFS_Allocate has a 32-bit version signature. Do not you observe the warning à la "tbb_debug.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'"?

If you still observe the issue, could you provide more details? What version of Intel TBB do you use (open source or composer version)?

Ritwik_D_1
Beginner
71 Views

I am using TBB 4.4 Update 3 (OS). I am not seeing the warning that you mentioned. When I remove the cache_aligned allocator code it works fine (I think the NFS functions are only in the cache_aligned allocator code).

Alexei_K_Intel
Employee
71 Views

Could you share a reproducer, e.g. gather all visual studio files into an archive and attach it to the message as media? If it is impossible due to confidentiality (or something else), let me know, please. 

Ritwik_D_1
Beginner
71 Views

Sorry I am not able to share a reproducer code because of confidentiality but a simple implementation of cache_aligned allocator in VS 2013 (any arch) should do the trick.

71 Views

hello, the dependencies are correct. these symbols are located at tbb.lib/tbb.dll files. have you added the folder where tbb.lib is located to %LIB% search variable? could you provide more linker output? it looks that linker can't find tbb.lib

--Vladimir 

Ritwik_D_1
Beginner
71 Views

Yes tbb.lib is added to the folder that I have passed as argument in the linker settings above. Also the linker output I mentioned above are the only errors I see.

Reply