C code generation symbols not found linker error

3 ビュー (過去 30 日間)
awezmm
awezmm 2020 年 8 月 9 日
編集済み: Ryan Livingston 2020 年 8 月 10 日
I generated C code for my matlab functions and created a package by following the instructions at Package Code for Other Development Environments.
I had configured code generation for example main files.
After everything was complete, I tried to compile my code using
clang main.c -o out
However, I get the error:
Undefined symbols for architecture x86_64:
"_cg_imadjust", referenced from:
_main_cg_imadjust in main-b5a3fb.o
"_cg_imadjust_terminate", referenced from:
_main in main-b5a3fb.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried looking up other solutions online but they mostly talk about mex file generation whereas I am trying to compile C code. Other solutions talked about having a main.c file but I already have one. I am confused on what the issue is.
I have attached my package zip file (that includes the main.c and main.h files). I am using Mac 10.15.6.
Thank you.

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 8 月 9 日

Ryan Livingston
Ryan Livingston 2020 年 8 月 10 日
編集済み: Ryan Livingston 2020 年 8 月 10 日
In your ZIP file you'll notice files cg_imadjust.c, cg_imadjust_interminate.c that also need to be compiled and linked. main.c calls functions implemented in those files causing this error.
Try something like
clang *.c *.dylib
to compile and link in all of the C files and shared libraries to avoid those and other errors.

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by