Azzera filtri
Azzera filtri

Compile and loadlibrary() issues.

19 visualizzazioni (ultimi 30 giorni)
Xymbu il 30 Giu 2022
Risposto: Maneet Kaur Bagga il 13 Set 2023
I compile a simple function using this command in the command prompt...
mcc -v -B csharedlib:InputTest InputTest.m
Then, to try to test the library I try to load it in using the load library function...
Then, I get a huge amount of errors. Theres thousands of lines of erros but here's an example...
Error using loadlibrary
Building InputTest_thunk_pcwin64 failed. Compiler output is:
C:\ProgramData\MATLAB\SupportPackages\R2021b\3P.instrset\mingw_w64.instrset\bin\gcc -I"C:\Program
Files\MATLAB\R2021b\extern\include" -fexceptions -fno-omit-frame-pointer
-I"C:\Users\User\Desktop\Testing Folder\Matlab dll" -I"C:\Users\User\Desktop\Testing
Folder\Matlab dll" "InputTest_thunk_pcwin64.c" -o "InputTest_thunk_pcwin64.dll" -shared
In file included from C:\Program Files\MATLAB\R2021b\extern\include/mclmcrrt.h:741:0,
from C:\Users\User\Desktop\Testing Folder\Matlab dll/InputTest.h:15,
from InputTest_thunk_pcwin64.c:27:
C:\Program Files\MATLAB\R2021b\extern\include/mclbase.h:23:0: warning: "DLL_EXPORT_SYM" redefined
#define DLL_EXPORT_SYM __attribute__ ((visibility("default")))
Does anybody understand whats going on here?

Risposte (1)

Maneet Kaur Bagga
Maneet Kaur Bagga il 13 Set 2023
Hi Xymbu,
As per my understanding of the question, the above command is being used to compile a MATLAB function file(InputTest.m) into a shared library named "InputTest" using the MATLAB compiler.
The "loadlibrary" function is being used to load the shared library and its associated header file("InputTest.h"). The command runs successfully depending on the availability of the header file "InputTest.dll" on the path and the correct association of the header file "InputTest.h" with the library.
The error message suggests that there was an issue while building the InputTest_thunk_pcwin64.dll library using the MinGW-w64 compiler. The error message also includes a warning related to the redefinition of DLL_EXPORT_SYM in the mclbase.h file.
Here are some of the troubleshooting steps you can follow to resolve the error:
  1. Check that the paths provided for the input files (InputTest.dll and InputTest.h) are located in the specified directories and accessible.
  2. If MATLAB function or the associated header file depends on external libraries, make sure that those libraries are correctly installed and accessible to the compiler.
  3. Check if the MATLAB Compiler version being used is compatible with the MATLAB version installed on your system. To check the compatibility you may use the "ver" command in the Command Prompt to display the MATLAB version along with all the toolboxes including MATLAB Compiler with their version.
----------------------------------------------------------------------------------------------------- MATLAB Version: (R2023a) Update 5 MATLAB License Number: 0 Operating System: Linux 5.4.233-0504233-generic #202302250651 SMP Sat Feb 25 12:26:27 UTC 2023 x86_64 Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode ----------------------------------------------------------------------------------------------------- MATLAB Version 9.14 (R2023a) Simulink Version 10.7 (R2023a) 5G Toolbox Version 2.6 (R2023a) Aerospace Blockset Version 6.0 (R2023a) Aerospace Toolbox Version 4.4 (R2023a) Antenna Toolbox Version 5.4 (R2023a) Audio Toolbox Version 3.4 (R2023a) Automated Driving Toolbox Version 3.7 (R2023a) Bioinformatics Toolbox Version 4.17 (R2023a) Bluetooth Toolbox Version 1.2 (R2023a) Communications Toolbox Version 8.0 (R2023a) Computer Vision Toolbox Version 10.4 (R2023a) Control System Toolbox Version 10.13 (R2023a) Curve Fitting Toolbox Version 3.9 (R2023a) DO Qualification Kit Version 3.15 (R2023a) DSP System Toolbox Version 9.16 (R2023a) Database Toolbox Version 11.0 (R2023a) Datafeed Toolbox Version 6.4 (R2023a) Deep Learning Toolbox Version 14.6 (R2023a) Econometrics Toolbox Version 6.2 (R2023a) Embedded Coder Version 7.10 (R2023a) Filter Design HDL Coder Version 3.1.13 (R2023a) Financial Instruments Toolbox Version 3.6 (R2023a) Financial Toolbox Version 6.5 (R2023a) Fixed-Point Designer Version 7.6 (R2023a) Fuzzy Logic Toolbox Version 3.1 (R2023a) Global Optimization Toolbox Version 4.8.1 (R2023a) HDL Coder Version 4.1 (R2023a) HDL Verifier Version 7.1 (R2023a) IEC Certification Kit Version 4.0 (R2023a) Image Acquisition Toolbox Version 6.7.1 (R2023a) Image Processing Toolbox Version 11.7 (R2023a) Industrial Communication Toolbox Version 6.2 (R2023a) Instrument Control Toolbox Version 4.8 (R2023a) LTE Toolbox Version 3.9 (R2023a) MATLAB Compiler Version 8.6 (R2023a) MATLAB Compiler SDK Version 7.2 (R2023a) MATLAB Report Generator Version 5.14 (R2023a) Mapping Toolbox Version 5.5 (R2023a) Mixed-Signal Blockset Version 2.4 (R2023a) Model Predictive Control Toolbox Version 8.1 (R2023a) Navigation Toolbox Version 2.4 (R2023a) Optimization Toolbox Version 9.5 (R2023a) Parallel Computing Toolbox Version 7.8 (R2023a) Partial Differential Equation Toolbox Version 3.10 (R2023a) Phased Array System Toolbox Version 5.0 (R2023a) Powertrain Blockset Version 2.0 (R2023a) Predictive Maintenance Toolbox Version 2.7 (R2023a) RF Blockset Version 8.5 (R2023a) RF Toolbox Version 4.5 (R2023a) Requirements Toolbox Version 2.2 (R2023a) Risk Management Toolbox Version 2.2 (R2023a) Robotics System Toolbox Version 4.2 (R2023a) Robust Control Toolbox Version 6.11.3 (R2023a) Sensor Fusion and Tracking Toolbox Version 2.5 (R2023a) SerDes Toolbox Version 3.0 (R2023a) Signal Processing Toolbox Version 9.2 (R2023a) SimBiology Version 6.4.1 (R2023a) SimEvents Version 5.14 (R2023a) Simscape Version 5.5 (R2023a) Simscape Driveline Version 3.7 (R2023a) Simscape Electrical Version 7.9 (R2023a) Simscape Fluids Version 3.6 (R2023a) Simscape Multibody Version 7.7 (R2023a) Simulink 3D Animation Version 9.6 (R2023a) Simulink Check Version 6.2 (R2023a) Simulink Code Inspector Version 4.3 (R2023a) Simulink Coder Version 9.9 (R2023a) Simulink Control Design Version 7.0 (R2023a) Simulink Coverage Version 5.6 (R2023a) Simulink Design Optimization Version 3.13 (R2023a) Simulink Design Verifier Version 4.9 (R2023a) Simulink PLC Coder Version 3.8 (R2023a) Simulink Real-Time Version 8.2 (R2023a) Simulink Report Generator Version 5.14 (R2023a) Simulink Test Version 3.8 (R2023a) Stateflow Version 10.8 (R2023a) Statistics and Machine Learning Toolbox Version 12.5 (R2023a) Symbolic Math Toolbox Version 9.3 (R2023a) System Identification Toolbox Version 10.1 (R2023a) Text Analytics Toolbox Version 1.10 (R2023a) Vehicle Dynamics Blockset Version 2.0 (R2023a) Vehicle Network Toolbox Version 5.4 (R2023a) Vision HDL Toolbox Version 2.7 (R2023a) WLAN Toolbox Version 3.6 (R2023a) Wavelet Toolbox Version 6.3 (R2023a) Wireless HDL Toolbox Version 2.6 (R2023a)
If none of the above steps work, then there might be more relevant information further down the error log. Review the complete error message to see if there are any additional details or specific errors that can help identify the problem.
Please refer to the following "loadlibrary" documentation for better understanding of the function.
Hope this helps!
Thank You
Maneet Bagga


Scopri di più su C Shared Library Integration in Help Center e File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by