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

조회 수: 8 (최근 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 CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by