0

我正在尝试启动并运行本文中的代码,但是,我遇到了我的宿敌 LNK2019 和 LNK2001。这是下载项目 zip 文件的直接链接。在有人问之前,我已经阅读了未解决的外部符号问题。它帮助我弄清楚了一些事情,但我仍然无法弄清楚这个问题。

问题与链接到TBB 库有关。项目代码似乎是在 2009 年的某个时候编写的,当时 TBB 是 2.X 版。最新的稳定版本(我正在尝试使用的版本)是 4.2。我找不到用于项目测试的版本,所以我无法确认。我也更喜欢使用最新版本的库。

谁能帮我确定这些链接器错误是由于项目代码和 TBB 之间的 api 不匹配,还是我没有正确设置我的环境变量/属性页?我正在使用 MSVS2010 Express。

以下是错误:

1>------ Build started: Project: VorteGrid, Configuration: Debug Win32 ------
1>inteSiVis.obj : error LNK2019: unresolved external symbol "public: void __thiscall tbb::task_scheduler_init::initialize(int,unsigned int)" (?initialize@task_scheduler_init@tbb@@QAEXHI@Z) referenced in function "public: __thiscall tbb::task_scheduler_init::task_scheduler_init(int,unsigned int)" (??0task_scheduler_init@tbb@@QAE@HI@Z)
1>inteSiVis.obj : error LNK2019: unresolved external symbol "void __cdecl tbb::assertion_failure(char const *,int,char const *,char const *)" (?assertion_failure@tbb@@YAXPBDH00@Z) referenced in function "public: __thiscall tbb::task_scheduler_init::task_scheduler_init(int,unsigned int)" (??0task_scheduler_init@tbb@@QAE@HI@Z)
1>vortonSim.obj : error LNK2001: unresolved external symbol "void __cdecl tbb::assertion_failure(char const *,int,char const *,char const *)" (?assertion_failure@tbb@@YAXPBDH00@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "void __cdecl tbb::assertion_failure(char const *,int,char const *,char const *)" (?assertion_failure@tbb@@YAXPBDH00@Z)
1>inteSiVis.obj : error LNK2019: unresolved external symbol "public: void __thiscall tbb::task_scheduler_init::terminate(void)" (?terminate@task_scheduler_init@tbb@@QAEXXZ) referenced in function "public: __thiscall tbb::task_scheduler_init::~task_scheduler_init(void)" (??1task_scheduler_init@tbb@@QAE@XZ)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: __thiscall tbb::task_group_context::~task_group_context(void)" (??1task_group_context@tbb@@QAE@XZ) referenced in function "public: static void __cdecl tbb::interface6::internal::start_for<class tbb::blocked_range<unsigned int>,class VortonSim_ComputeVelocityGrid_TBB,class tbb::auto_partitioner const >::run(class tbb::blocked_range<unsigned int> const &,class VortonSim_ComputeVelocityGrid_TBB const &,class tbb::auto_partitioner const &)" (?run@?$start_for@V?$blocked_range@I@tbb@@VVortonSim_ComputeVelocityGrid_TBB@@$$CBVauto_partitioner@2@@internal@interface6@tbb@@SAXABV?$blocked_range@I@4@ABVVortonSim_ComputeVelocityGrid_TBB@@ABVauto_partitioner@4@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: __thiscall tbb::task_group_context::~task_group_context(void)" (??1task_group_context@tbb@@QAE@XZ)
1>vortonSim.obj : error LNK2019: unresolved external symbol "protected: void __thiscall tbb::task_group_context::init(void)" (?init@task_group_context@tbb@@IAEXXZ) referenced in function "public: __thiscall tbb::task_group_context::task_group_context(enum tbb::task_group_context::kind_type,unsigned int)" (??0task_group_context@tbb@@QAE@W4kind_type@01@I@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "protected: void __thiscall tbb::task_group_context::init(void)" (?init@task_group_context@tbb@@IAEXXZ)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int)const " (?allocate@allocate_root_with_context_proxy@internal@tbb@@QBEAAVtask@3@I@Z) referenced in function "void * __cdecl operator new(unsigned int,class tbb::internal::allocate_root_with_context_proxy const &)" (??2@YAPAXIABVallocate_root_with_context_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int)const " (?allocate@allocate_root_with_context_proxy@internal@tbb@@QBEAAVtask@3@I@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: void __thiscall tbb::internal::allocate_root_with_context_proxy::free(class tbb::task &)const " (?free@allocate_root_with_context_proxy@internal@tbb@@QBEXAAVtask@3@@Z) referenced in function "void __cdecl operator delete(void *,class tbb::internal::allocate_root_with_context_proxy const &)" (??3@YAXPAXABVallocate_root_with_context_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: void __thiscall tbb::internal::allocate_root_with_context_proxy::free(class tbb::task &)const " (?free@allocate_root_with_context_proxy@internal@tbb@@QBEXAAVtask@3@@Z)
1>vortonSim.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall tbb::task::note_affinity(unsigned short)" (?note_affinity@task@tbb@@UAEXG@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall tbb::task::note_affinity(unsigned short)" (?note_affinity@task@tbb@@UAEXG@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl tbb::internal::get_initial_auto_partitioner_divisor(void)" (?get_initial_auto_partitioner_divisor@internal@tbb@@YAIXZ) referenced in function "public: __thiscall tbb::interface6::internal::auto_partition_type_base<class tbb::interface6::internal::auto_partition_type>::auto_partition_type_base<class tbb::interface6::internal::auto_partition_type>(void)" (??0?$auto_partition_type_base@Vauto_partition_type@internal@interface6@tbb@@@internal@interface6@tbb@@QAE@XZ)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "unsigned int __cdecl tbb::internal::get_initial_auto_partitioner_divisor(void)" (?get_initial_auto_partitioner_divisor@internal@tbb@@YAIXZ)
1>vortonSim.obj : error LNK2019: unresolved external symbol "private: void __thiscall tbb::task::internal_set_ref_count(int)" (?internal_set_ref_count@task@tbb@@AAEXH@Z) referenced in function "public: void __thiscall tbb::task::set_ref_count(int)" (?set_ref_count@task@tbb@@QAEXH@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "private: void __thiscall tbb::task::internal_set_ref_count(int)" (?internal_set_ref_count@task@tbb@@AAEXH@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: bool __thiscall tbb::task_group_context::is_group_execution_cancelled(void)const " (?is_group_execution_cancelled@task_group_context@tbb@@QBE_NXZ) referenced in function "public: bool __thiscall tbb::task::is_cancelled(void)const " (?is_cancelled@task@tbb@@QBE_NXZ)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: bool __thiscall tbb::task_group_context::is_group_execution_cancelled(void)const " (?is_group_execution_cancelled@task_group_context@tbb@@QBE_NXZ)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_child_proxy::allocate(unsigned int)const " (?allocate@allocate_child_proxy@internal@tbb@@QBEAAVtask@3@I@Z) referenced in function "void * __cdecl operator new(unsigned int,class tbb::internal::allocate_child_proxy const &)" (??2@YAPAXIABVallocate_child_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_child_proxy::allocate(unsigned int)const " (?allocate@allocate_child_proxy@internal@tbb@@QBEAAVtask@3@I@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: void __thiscall tbb::internal::allocate_child_proxy::free(class tbb::task &)const " (?free@allocate_child_proxy@internal@tbb@@QBEXAAVtask@3@@Z) referenced in function "void __cdecl operator delete(void *,class tbb::internal::allocate_child_proxy const &)" (??3@YAXPAXABVallocate_child_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: void __thiscall tbb::internal::allocate_child_proxy::free(class tbb::task &)const " (?free@allocate_child_proxy@internal@tbb@@QBEXAAVtask@3@@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_continuation_proxy::allocate(unsigned int)const " (?allocate@allocate_continuation_proxy@internal@tbb@@QBEAAVtask@3@I@Z) referenced in function "void * __cdecl operator new(unsigned int,class tbb::internal::allocate_continuation_proxy const &)" (??2@YAPAXIABVallocate_continuation_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: class tbb::task & __thiscall tbb::internal::allocate_continuation_proxy::allocate(unsigned int)const " (?allocate@allocate_continuation_proxy@internal@tbb@@QBEAAVtask@3@I@Z)
1>vortonSim.obj : error LNK2019: unresolved external symbol "public: void __thiscall tbb::internal::allocate_continuation_proxy::free(class tbb::task &)const " (?free@allocate_continuation_proxy@internal@tbb@@QBEXAAVtask@3@@Z) referenced in function "void __cdecl operator delete(void *,class tbb::internal::allocate_continuation_proxy const &)" (??3@YAXPAXABVallocate_continuation_proxy@internal@tbb@@@Z)
1>particleRenderer.obj : error LNK2001: unresolved external symbol "public: void __thiscall tbb::internal::allocate_continuation_proxy::free(class tbb::task &)const " (?free@allocate_continuation_proxy@internal@tbb@@QBEXAAVtask@3@@Z)
1>VorteGrid\Debug\VorteGrid.exe : fatal error LNK1120: 15 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

更新

我设法让 CFD 代码启动并运行!耶 :) 问题是我在 64 位机器上,但我使用的是 32 位版本的 MSVS2010 express。我没有意识到这一点,我试图使用 intel64 库(即 ...\tbb\lib\intel64\vc10)。不知何故,这个问题表现在链接器错误中,这实际上没有意义。无论如何,切换到 ia32 解决了这个问题,并且项目将建立。

下一个障碍是应用程序抱怨一些非描述性错误,例如“程序出现错误([注册表代码])”。所以我最终尝试运行 TBB 示例。这些示例在运行时给出了更清晰的错误,说“您的计算机中缺少 tbb.dll 文件。请尝试重新安装程序”。经过一番谷歌搜索,我找到了一个简单的解决方案:将它抱怨的 dll 文件移动到应用程序目录中。

然后,终于,应用程序工作了。视觉效果非常值得。我等不及要开始玩这个了。

4

1 回答 1

1

这些错误是由某些环境/配置问题引起的。

通常,较新的 TBB 版本与较旧的版本兼容(在源代码和二进制级别上)。所示错误中提到的特定符号用于核心 TBB 功能;它们有一段时间没有改变,而且肯定存在于 4.2 版本的二进制文件中。

于 2013-10-11T08:23:13.163 回答