Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

TBB Linker error on vs2010 { "__declspec(dllimport) int __cdecl InitializeCriticalSectionAndSpinCount }

singh__avanindra
Beginner
589 Views

Hi All ,

I have written an image processing related code. I used TBB for parallel implementation of computationally intensive for loops. The program runs fine on Linux. I am trying to port it on windows. When I try to build the executable , I get following linker error:

 

Error 61 error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl InitializeCriticalSectionAndSpinCount(struct _RTL_CRITICAL_SECTION *,unsigned long)" (__imp_?InitializeCriticalSectionAndSpinCount@@YAHPEAU_RTL_CRITICAL_SECTION@@K@Z) referenced in function "int __cdecl inlineInitializeCriticalSectionEx(struct _RTL_CRITICAL_SECTION *,unsigned long,unsigned long)" (?inlineInitializeCriticalSectionEx@@YAHPEAU_RTL_CRITICAL_SECTION@@KK@Z) D:\projects\rocs_winmain\build\vs2010\release\test\feature_detection\vlfeat_interface.lib(affinefeaturedetector.obj)

I have linked the executable with tbb libraries ( tbb.lib , tbbmalloc.lib , tbbmalloc_proxy.lib ). What could I have to possibly link more to remove this linking error?...

The linking problem is coming from TBB only , because when I comment out the tbb implementation , my programs runs just fine.

Regards

Avanindra Singh 

0 Kudos
4 Replies
Vladimir_P_1234567890
589 Views

Hello Avanindra Singh

Do you use /nodefaultlib linker key? if yes you need to add Kernel32.lib to libraries.

--Vladimir

0 Kudos
singh__avanindra
Beginner
589 Views

Hi Vladimir,

Thanks for the reply. I am not using  /nodefaultlib linker flag , though I tried explicitly to link Kernel32.lib , but the problem still persists.

Regards

Avanindra 

0 Kudos
Vladimir_P_1234567890
589 Views

what is operation system and target SDK (_WIN32_WINNT macro setting)?

0 Kudos
singh__avanindra
Beginner
589 Views

I am using Windows 7 and I set explicitly  _WIN32_WINNT to 0x0501 at the start of the cpp file before including tbb headers. I am using msvc 2010 , x64 . Also my program , uses OpenCV and vlFeat external libraries. Could the problem also come from external libraries ?.. I mean OpenCV has option of internally using TBB ( which I have disbled , it's compiled without TBB ). 

0 Kudos
Reply