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

Including tbb\\flow_graph.h causes linker error LNK1169 (one or more multiply defined symbols found)

rythblade
Beginner
469 Views
Hi folks,
First time poster, but I hope you can help me out.
I'm trying to implement a DLL that makes use of the tbb flo graph, however every time I try and include the library from ANYWHERE other than the dllmain file, I get a linkererrors.
Note: somewhere through the include chain the flow graph header file is included in dllmain. E.g. some object includes the flow graph, which is included by another, which is in tern included in the dllmain function file.
If there is not an include chain between the file including the flow graph and the dllmain function file, then there are no compile problems.
I can successfully include the flow graph among the exported functions, classes and variables etc.
Here are the link errors:
[bash]Error 3 error LNK1169: one or more multiply defined symbols found C:\Users\q285032\Desktop\dfsadgsaasdgasdg\Debug\dfsadgsaasdgasdg.dll 1 Error 1 error LNK2005: "private: void __thiscall tbb::flow::interface6::graph::register_node(class tbb::flow::interface6::graph_node *)" (?register_node@graph@interface6@flow@tbb@@AAEXPAVgraph_node@234@@Z) already defined in dllmain.obj C:\Users\q285032\Desktop\dfsadgsaasdgasdg\dfsadgsaasdgasdg\stdafx.obj Error 2 error LNK2005: "private: void __thiscall tbb::flow::interface6::graph::remove_node(class tbb::flow::interface6::graph_node *)" (?remove_node@graph@interface6@flow@tbb@@AAEXPAVgraph_node@234@@Z) already defined in dllmain.obj C:\Users\q285032\Desktop\dfsadgsaasdgasdg\dfsadgsaasdgasdg\stdafx.obj [/bash]
I am able to include other tbb headers like tbb.h and atomic.h etc.
I've been able to reproduce this with no problems using a Visual Studio 2010 wizrd produced dll project with no changes other than adding the #include "tbb\\flow_graph.h" statement (I've also tried it in the form#include and get the same results).
Steps to reproduce:
Open Visual Studio 2010, create a new C++ win32 console application using the wizard, making sure you select the "DLL" radio button and tick the "Export Symbols" check box - don't change any other settings.
Hit finish.
Set up the include and librarie dependencies to point to the TBB libraries - I've been using the Visual Studio add-on available on the website - but I've also tried it manually and had the same problem.
Now add the statement#include "tbb\\flow_graph.h" to the file "stdafx.h" and compile the project. You should get a few link errors similar to mine. If you move the statement to the "dllmain.cpp" file it will compile without problem. Also if you place it in the API export classes it will compile without problems.
I'm using the latest commercially aligned version -tbb40_297ossfromhttp://threadingbuildingblocks.org
I've got no clue how to fix this and I'm in desperate need of it flow graph functionality.
I've tried all the ways I can think of to debug this but reproducing it in a blank project is worrying.
ANY help/fixes/workarounds will be greatly appreciated!
Thanks!
0 Kudos
6 Replies
Alexey-Kukanov
Employee
469 Views
Thank you for reporting the issue. I will make sure it is fixed.

For the workaround, can you find the following two lines in flow_graph.h
[bash] void register_node(graph_node *n); void remove_node(graph_node *n); [/bash]
and modify them to declare functions as inline (i.e. add inline keyword in front of each line)?
0 Kudos
rythblade
Beginner
469 Views
Thanks very much, that worked brilliantly!
When is the fix likely to be formally release - when is the next scheduled update??
Will I need to re-complile the distributed tbb DLL's with this fix for when I release my package??
0 Kudos
Alexey-Kukanov
Employee
469 Views
You don't need to recompile TBB; the change does not affect its binaries, only headers. And basically this change is the realfix, so you don't have to wait for the next release. Anyway, it's tentatively planned to April.
0 Kudos
rythblade
Beginner
469 Views
That's great, thanks very much for your help with this! Especially the fast response!!

Thanks again!
0 Kudos
rmbianchi
Beginner
469 Views
Anyway, it's tentatively planned to April.

Hi Alexey,

I had exactly the same problem and your suggestion worked like a charm! Thanks a lot for this fix! :-)

By the way, I just downloaded the TBB 4.0 Update 4 and the fix is not there yet. Do you plan to officially release it in one of the next releases?

Cheers,

Ric.

0 Kudos
Vladimir_P_1234567890
469 Views
Quoting rmbianchi

By the way, I just downloaded the TBB 4.0 Update 4 and the fix is not there yet. Do you plan to officially release it in one of the next releases?

Oopps, everyone was sure that the fix had been checked-in:)
It will be available in next update.
--Vladimir
0 Kudos
Reply