Как связать MinGW (г cc) и TBB - PullRequest
       44

Как связать MinGW (г cc) и TBB

0 голосов
/ 17 апреля 2020

Я пытаюсь скомпилировать свою программу TBB, используя MinGW. Я знаю, что TBB правильно установлен на моей машине, потому что он прекрасно компилируется в Visual Studio. Должен ли я сделать что-то еще, чтобы сообщить MinGW, где установлен TBB? Или просто связываете библиотеку все, что нужно? Я получаю эти ошибки, когда пытаюсь скомпилировать с помощью g cc.

 C:\Users\Owner\Desktop\New folder\OpenMP vs TBB>make
g++  -LC:\tbb\tbb\lib\intel64\vc14 -O3 -o pps avl.o main.o parPlaneSweep.o -fopenmp -ltbb
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x433f): undefined reference to `tbb::task_group_context::init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x435d): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x439d): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x43d0): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x47d5): undefined reference to `tbb::task_group_context::init()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x47f3): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x4835): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x4868): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7743): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x776c): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7a66): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7abc): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x7ae5): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8cab): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8cd4): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8f69): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8fb4): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text+0x8fdd): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x43): undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x4e): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x73): undefined reference to `tbb::interface5::internal::task_base::destroy(tbb::task&)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x87): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0xe3): undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0xf1): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x10b): undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD1Ev[__ZN3tbb4flow11interface105graphD1Ev]+0x12e): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x44): undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x4f): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x74): undefined reference to `tbb::interface5::internal::task_base::destroy(tbb::task&)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x88): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0xf3): undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x101): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x11b): undefined reference to `tbb::interface7::internal::task_arena_base::internal_initialize()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text$_ZN3tbb4flow11interface105graphD0Ev[__ZN3tbb4flow11interface105graphD0Ev]+0x13e): undefined reference to `tbb::task_group_context::reset()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0xf3): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0xff): undefined reference to `tbb::task_group_context::~task_group_context()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.text.unlikely+0x118): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: parPlaneSweep.o:parPlaneSweep.cpp:(.rdata$_ZTVN3tbb10interface98internal9flag_taskE[__ZTVN3tbb10interface98internal9flag_taskE]+0x14): undefined reference to `tbb::task::note_affinity(unsigned short)'
collect2.exe: error: ld returned 1 exit status
Makefile:10: recipe for target 'pps' failed
make: *** [pps] Error 1

Вот так выглядит мой текущий Makefile прямо сейчас.

CC=gcc
CPLUSPLUS = g++ 
OPTFLAGS = -O3
TBB_INCLUDE_PATH = C:\tbb-2020.1-win\tbb\include
TBB_LIBRARY_PATH = C:\tbb\tbb\lib\intel64\vc14

all: pps

pps: avl.o main.o parPlaneSweep.o
    $(CPLUSPLUS) -L$(TBB_LIBRARY_PATH) $(OPTFLAGS) -o $@ $^ -fopenmp -ltbb

avl.o: avl.h avl.c
    $(CC) -c $(OPTFLAGS) -fPIC avl.c

main.o: main.cpp parPlaneSweep.h
    $(CPLUSPLUS) -c $(OPTFLAGS) -fopenmp main.cpp 

parPlaneSweep.o: parPlaneSweep.h parPlaneSweep.cpp
    $(CPLUSPLUS) -c $(OPTFLAGS) -ITBB_INCLUDE_PATH -fPIC -fopenmp parPlaneSweep.cpp

clean:
    rm *.o
    rm pps

1 Ответ

0 голосов
/ 24 апреля 2020

MinGW и MSV C - это разные наборы инструментов, хотя оба могут создавать файлы EXE / DLL в «родном» формате Windows. Но оформление символов C ++ (иначе говоря) происходит по-разному, поэтому одна и та же функция в исходном коде будет скомпилирована в бинарные функции с разными именами. Также может быть больше различий между бинарными интерфейсами приложений (ABI). Поэтому вы не можете просто связать объектные файлы / библиотеки, созданные / для MinGW и / для MSVC; вам нужно, чтобы все библиотеки были подготовлены с использованием одной и той же цепочки инструментов.

Вы можете создавать двоичные файлы TBB для MinGW самостоятельно (это поддерживается в make-файлах TBB), или вы можете попробовать найти готовый к использованию пакет, такой как тот для MSYS2, упомянутый в комментариях к вопросу.

...