Community
cancel
Showing results for 
Search instead for 
Did you mean: 
riteshkapoor
Beginner
183 Views

Unable to link tbb.dll statically

Hi,

I'm trying to link the tbb.dll statically to my own dll in a Visual Studio 2008 project.

In my project settings, i've provided the path for the include directories of tbb. Under the Linker->General tab, i've provided the tbb.lib path for the directory with the name "vc_mt" and under Linker->Input tab i've provided the tbb.lib in Additional Dependecies.

Under C/C++ -> Code Generation -> Run Time Library i've set it to /MT.

The project builds properly. When i run my project/exe, it loads my dll which gives me a 'System Error' dialog stating that "The program can't start because tbb.dll is missing from your computer. Try reinstalling the program to fix this problem.".

If I place the tbb.dll next to my dll, and then launch, it gives the same error.

What I need is for the tbb.dll to get statically linked to my dll. Is there any way to get it done?

Thanks,
Ritesh

0 Kudos
5 Replies
183 Views

Hi Ritesh,

We do not support/provide static version of tbb.lib. vc_mt folder contains dlls which are statically linked to VC runtime.

which version of tbb.dll have you used when copied next to your library? it should be vc9\tbb.dll for visual studion 2008 or vc_mt\tbb.dll or version built on your machine.

And which tbb package was used?

thanks.
--Vladimir
e4lam
Beginner
183 Views

Are you sure you've done all of the following steps?
  • Under Configuration Properties > General, the Configuration Type should be Static Library (.lib).
  • Under Configuration Properties > C/C++, ensure that the compiler command line has /D__TBB_TASK_CPP_DIRECTLY_INCLUDED=1 instead of /DDO_ITT_NOTIFY
  • Under Configuration Properties > C/C++ > Code Generation, the Runtime Library should be "Multi-threaded (/MT)" for Release, and "Multi-threaded Debug (/MTd)" for Debug
  • Under Configuration Properties > Librarian > General, note the Output File name. It should be different between the Debug and Release configurations, with the Debug one usually having a _d or _debug suffix
  • Successfully recompiled your .dll with the static version of TBB

In the spirit of open-source, I've posted my patch to TBB for these changes at http://pastebin.com/2uwbzwky
It also includes some changes to MemoryAllocator.cpp to avoid extraneous warnings from Visual Studio 2005.

Note that there are several caveats with this approach (as noted before in this forum) so YMMV:
  • tbbmalloc's per-thread memory pool is not released whenever a thread terminates
  • other thread termination issues related to DllMain() no longer being used

Basically, if you're a third-party library then it can get very bad because of these caveats.
riteshkapoor
Beginner
183 Views

Hi Vladimir,

I'm using tbb 3.0 posted on April 22, 2010. I tried building with both vc_mt and vc9 folders containing tbb.dll.

Is there any specific reason why static lib is not supported?

Thanks

riteshkapoor
Beginner
183 Views

Thanks e4lam,

I created a build of tbb 3.0 posted on April 22, 2010 as a static lib. I'm able to statically link the tbb.lib to my dll.

I've run into another problem now, my application crashes 50% of the time its launched. I'm unable to figure out why thats happening.

I've been trying to repro the crash using a smaller code which I could share on the forum but haven't been able to so far.

Briefly - i'm using parallel_while and I need to share data across threads for which I pass and store a reference to the variables in the 'ApplyFunction' object (for which operator () is defined). Is there a different way to share variables across threads?

thanks
183 Views

Hi,

Take a look at DLLmain function which is not called in case you link statically. You need to initialize/de-initialize the library manually from your code in the same way.

--Vladimir.
Reply