bshoshany / thread-pool

BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
MIT License
2.21k stars 253 forks source link

Error linking with version 4.0.0 #137

Closed Oberonc closed 10 months ago

Oberonc commented 10 months ago

First appears in version 4.0.0 (3.5.0 is fine)

Environment: GCC 12.2.0

Compiling looks like this (using cmake): [1/16] c++ -Ioperator.p -I. -I../.. -I../../include -I/usr/include/modbus -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++20 -O0 -g -pthread '-DOPERATOR_VERSION="1.0.1"' -MD -MQ operator.p/src_Parameters.cpp.o -MF operator.p/src_Parameters.cpp.o.d -o operator.p/src_Parameters.cpp.o -c ../../src/Parameters.cpp

Linking looks like this (using cmake): [16/16] c++ -o operator operator.p/src_main.cpp.o operator.p/src_Configuration.cpp.o operator.p/src_Parameters.cpp.o operator.p/src_Timer.cpp.o operator.p/src_MessageFactory.cpp.o operator.p/src_UpdateManager.cpp.o operator.p/src_model.cpp.o operator.p/src_ConfigurationFactory.cpp.o operator.p/src_ModbusBuffer.cpp.o operator.p/src_MqttClient.cpp.o operator.p/src_behavior_TidharBehaviorImplementer.cpp.o operator.p/src_elements_BatteryPack.cpp.o operator.p/src_elements_Grid.cpp.o operator.p/src_elements_Load.cpp.o operator.p/src_elements_PCS.cpp.o -Wl,--as-needed -Wl,--no-undefined -pthread -Wl,--start-group -ldl /usr/lib/libmodbus.so /usr/lib/libssl.so /usr/lib/libcrypto.so -lpaho-mqttpp3 -lpaho-mqtt3as -Wl,--end-group

Error during linking: /usr/bin/ld: operator.p/src_model.cpp.o:(.tbss+0x0): multiple definition of BS::this_thread::get_index'; operator.p/src_main.cpp.o:(.tbss+0x0): first defined here /usr/bin/ld: operator.p/src_model.cpp.o:(.tbss+0x10): multiple definition ofBS::this_thread::get_pool'; operator.p/src_main.cpp.o:(.tbss+0x10): first defined here

bshoshany commented 10 months ago

Thanks for opening this issue! This appears to be a duplicate of #134.