Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG ?] multiple definitions get_index, get_pool link fails with VS 2022 #134

Closed
Nelson-numerical-software opened this issue Dec 28, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Nelson-numerical-software

Describe the bug

in my specific environment on Windows, maybe not reproductible in others cases:
get_index, get_pool seems to be redefined each time that we include "#include <BS_thread_pool.hpp>"

4>LINK : D:\Developpements\Github\nelson-lang\nelson\bin\x64\libnlsParallel_builtin.dll introuvable ou non généré par la dernière édition de liens incrémentielle ; édition de liens complète en cours
4>backgroundPool_deleteBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_deleteBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_pool BS::this_thread::get_pool" (?get_pool@this_thread@BS@@3Vthread_info_pool@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_displayBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_displayBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_pool BS::this_thread::get_pool" (?get_pool@this_thread@BS@@3Vthread_info_pool@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_fieldnamesBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_fieldnamesBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_pool BS::this_thread::get_pool" (?get_pool@this_thread@BS@@3Vthread_info_pool@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_getBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_getBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_pool BS::this_thread::get_pool" (?get_pool@this_thread@BS@@3Vthread_info_pool@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_structBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_structBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_pool BS::this_thread::get_pool" (?get_pool@this_thread@BS@@3Vthread_info_pool@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj
4>backgroundPool_usedBuiltin.obj : error LNK2005: "class BS::this_thread::thread_info_index BS::this_thread::get_index" (?get_index@this_thread@BS@@3Vthread_info_index@12@A) déjà défini(e) dans backgroundPoolBuiltin.obj

workaround used (ugly ?)

add inline:

    inline thread_local thread_info_index get_index;
    inline thread_local thread_info_pool get_pool;

System information

  • CPU model, architecture, # of cores and threads:
  • Operating system: windows 11
  • Name and version of C++ compiler: VS 2022 17.8.3
  • Thread pool library version: 4.0 official release
@JanCaha
Copy link

JanCaha commented Dec 28, 2023

+1

I am getting the same error on Linux with g++-12 compiler.

@lucadesogus
Copy link

+1
Same issue on Debian 12 with g++12.2.0

@bshoshany
Copy link
Owner

Hi everyone, thanks for opening this issue! It does appear that changing these variables to inline resolves this issue. I will post a patch in a bit.

@bshoshany
Copy link
Owner

Update: This should now be resolved in v4.0.1. Please let me know if it is not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants