Why do I get a linker error when compiling MATLAB Coder output?

15 ビュー (過去 30 日間)
Shawn Rigdon
Shawn Rigdon 2019 年 5 月 30 日
編集済み: Walter Roberson 2020 年 8 月 6 日
I have generated C++ code for 2 MATLAB functions, and I have made a main file from the 2 examples. I have it compiling against the generated libraries, but I'm getting the following linker error:
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
I am using g++ version 7.4.0 and ld version 2.30
Using the --no-relax option results in several undefined reference errors to functions that are found in the libraries.
gen/libdata2image_mmw.a(data2image_mmw_initialize.o): In function `data2image_mmw_initialize()':
data2image_mmw_initialize.cpp:(.text+0x1a): undefined reference to `omp_init_nest_lock'
gen/libdata2image_mmw.a(data2image_mmw_terminate.o): In function `data2image_mmw_terminate()':
data2image_mmw_terminate.cpp:(.text+0x8): undefined reference to `omp_destroy_nest_lock'
gen/libdata2image_mmw.a(data2image_mmw.o): In function `data2image_mmw(creal_T const*, double const*, double, double, double, double, double*, double*, emxArray_real_T*, emxArray_creal_T*)':
data2image_mmw.cpp:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x14a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x151): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x1cc): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x1d7): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x21b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
data2image_mmw.cpp:(.text+0x222): additional relocation overflows omitted from the output
gen/libdata2image_mmw.a(fft1.o): In function `b_r2br_r2dit_trig(creal_T const*, double const*, double const*, creal_T*) [clone ._omp_fn.0]':
fft1.cpp:(.text+0x218): undefined reference to `omp_get_num_threads'
fft1.cpp:(.text+0x220): undefined reference to `omp_get_thread_num'
gen/libdata2image_mmw.a(fft1.o): In function `r2br_r2dit_trig(creal_T const*, double const*, double const*, creal_T*) [clone ._omp_fn.1]':
fft1.cpp:(.text+0x348): undefined reference to `omp_get_num_threads'
fft1.cpp:(.text+0x350): undefined reference to `omp_get_thread_num'
gen/libdata2image_mmw.a(fft1.o): In function `b_r2br_r2dit_trig(creal_T const*, double const*, double const*, creal_T*)':
fft1.cpp:(.text+0x496): undefined reference to `omp_get_max_threads'
fft1.cpp:(.text+0x4c0): undefined reference to `GOMP_parallel'
gen/libdata2image_mmw.a(fft1.o): In function `r2br_r2dit_trig(creal_T const*, double const*, double const*, creal_T*)':
fft1.cpp:(.text+0x564): undefined reference to `omp_get_max_threads'
fft1.cpp:(.text+0x58e): undefined reference to `GOMP_parallel'
collect2: error: ld returned 1 exit status
  4 件のコメント
Anakin Zheng
Anakin Zheng 2019 年 6 月 10 日
Hi Shawn,
Can you share the linker command you are using?
Thanks
Ahmad Alghooneh
Ahmad Alghooneh 2020 年 8 月 3 日
Link OpenMp with your compiler

サインインしてコメントする。

回答 (1 件)

Ashrarul Sifat
Ashrarul Sifat 2020 年 2 月 5 日
Did you solve this? Also the link from the previous answer is unavailbe now

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by