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

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

rythblade's picture

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:

Error	3	error LNK1169: one or more multiply defined symbols found	C:Usersq285032DesktopdfsadgsaasdgasdgDebugdfsadgsaasdgasdg.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:Usersq285032Desktopdfsadgsaasdgasdgdfsadgsaasdgasdgstdafx.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:Usersq285032Desktopdfsadgsaasdgasdgdfsadgsaasdgasdgstdafx.obj

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!

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Alexey Kukanov (Intel)'s picture

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

    void register_node(graph_node *n);

    void remove_node(graph_node *n);


and modify them to declare functions as inline (i.e. add inline keyword in front of each line)?

rythblade's picture

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??

Alexey Kukanov (Intel)'s picture

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.

rythblade's picture

That's great, thanks very much for your help with this! Especially the fast response!!

Thanks again!

rmbianchi's picture
Quoting Alexey Kukanov (Intel) 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.

Vladimir Polin (Intel)'s picture
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

Login to leave a comment.