フィルターのクリア

Compiler issue? -> Building CoolPropLi​brary_thun​k_maci64 failed. Compiler output is: /usr/bin/xcrun -sdk macosx12.3 clang -I". zsh:1: unmatched "

2 ビュー (過去 30 日間)
Julian Thoma
Julian Thoma 2022 年 5 月 31 日
編集済み: Dinesh 2023 年 10 月 25 日
I want to load a library (CoolPropLib.h) into my Matlab project. Here is the Code I am using to load the library:
%% Initializing CoolProp
path_to_lib = '.\CoolProp\CoolProp_Shared_Library_Mac_6.3.0'; %specify path to coolprop shared library
path_to_include= '.\CoolProp\CoolProp_Shared_Library_Mac_6.3.0'; %specify path to coolprop's include folder
if ~libisloaded('CoolPropLibrary') %checking whether library is already loaded
addpath(path_to_lib)
addpath(path_to_include)
libname = 'libCoolProp'; % OSX and linux
if ispc
libname = 'CoolProp';
end
loadlibrary(libname,'CoolPropLib.h','includepath',path_to_include,'alias','CoolPropLibrary'); % loading library with alias coolprop
disp('loaded CoolProp shared library.');
disp('loaded these functions: ');
libfunctions CoolPropLibrary;
end
But I am getting the following error message:
Building CoolPropLibrary_thunk_maci64 failed. Compiler output is: /usr/bin/xcrun -sdk macosx12.3 clang -I". zsh:1: unmatched "
The message apparantly is in line 11 (loadlibrary(libname, 'CoolPropLib.h', ... .
So far the only advice I could find is to use a supported compiler, which I do:
Could there still be something wrong with the compiler or is the problem elsewhere?
Just in case this is relevant: I am on version 12.3.1 of macOS Monterey and I use a MacBook Air (M1, 2020).

回答 (1 件)

Dinesh
Dinesh 2023 年 10 月 25 日
編集済み: Dinesh 2023 年 10 月 25 日
Hi Julian!
I understand that you are trying to load a header file in MATLAB using the 'loadlibrary' function. However, you are encountering an error that says 'zsh:1: unmatched "'.
Assuming the header file is written in C. Based on the error message 'zsh:1: unmatched "', it is likely that the problem is caused by an unmatched double quote character on the first line of your header file. To resolve this issue, open the header file and ensure that all the double quote characters are properly matched. Additionally, check if any other braces or parentheses are also matched correctly. Once you have made these changes, try running the code again. This should fix the error and allow the build to proceed smoothly.
If the header file you have is in C++, then the error you are encountering is likely because the 'loadlibrary' function in MATLAB only supports calling functions that are callable from C. It means that header files must be able to be parsed by a C compiler.
To resolve this issue and call functions written in C++, you need to declare them as extern 'C'. This declaration ensures that the C++ functions are compatible with the C calling convention.
If you want to call a C++ functions completely, please refer to the following MATLAB documentation
Hope this helps!

カテゴリ

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