Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
university:tools:m2k:matlab [15 Jul 2020 22:17] – Minor tweaks Travis Collinsuniversity:tools:m2k:matlab [11 May 2023 10:46] – Instructions to ma Ionut Muthi
Line 5: Line 5:
 ====== Quick Start ====== ====== Quick Start ======
  
-To get started with libm2k+MATLAB there are integrated installers available for [[https://www.mathworks.com/matlabcentral/fileexchange/74385-libm2k-matlab|Windows]]. Simply download the MLTBX file and open it within MATLAB. This will install the necessary libraries and classes to interface with M2K. The Windows installer packages the dependent libraries libiio, libm2k, and the MATLAB bindings so they do not need to be installed externally. The only requirement is the [[https://wiki.analog.com/university/tools/pluto/drivers/windows|M2K driver]]. For Linux support see the [[#Linux Support|section below]].+To get started with libm2k+MATLAB there are integrated installers available for [[mw>matlabcentral/fileexchange/74385-libm2k-matlab|Windows and Linux]]. Simply download the MLTBX file and open it within MATLAB. This will install the necessary libraries and classes to interface with M2K. The installer packages the dependent libraries libiio, libm2k, and the MATLAB bindings so they do not need to be installed externally. The only requirement is the [[/university/tools/pluto/drivers/windows|M2K driver]]. For manual build see the [[#Manual Build|section below]].
  
 After installation of the driver and the MLTBX file, you will have access to the bindings through [[mw>help/matlab/call-cpp-library-functions.html|MATLAB's clib interface for C++ libraries]]. For libm2k this will be in the form:<code>clib.libm2k.libm2k.<M2K classes> </code> After installation of the driver and the MLTBX file, you will have access to the bindings through [[mw>help/matlab/call-cpp-library-functions.html|MATLAB's clib interface for C++ libraries]]. For libm2k this will be in the form:<code>clib.libm2k.libm2k.<M2K classes> </code>
Line 85: Line 85:
 </code> </code>
  
-====== Linux Support ======+====== Manual Build ======
  
-Since libraries can vary across Linux distributions we no longer provide a packaged installer for the libm2k MATLAB bindings, but they can be easily built. They require two main dependencies which have build/install instructions: +You require two main dependencies which have build/install instructions (make sure you are using compatible versions)
   * [[>resources/tools-software/linux-software/libiio|libiio]]   * [[>resources/tools-software/linux-software/libiio|libiio]]
   * [[>university/tools/m2k/libm2k/libm2k|libm2k]]   * [[>university/tools/m2k/libm2k/libm2k|libm2k]]
Line 93: Line 93:
 Once these are built and installed the MATLAB bindings can be built. To do this follow these steps: Once these are built and installed the MATLAB bindings can be built. To do this follow these steps:
  
-Clone the repo+Inside libm2k repo go to /bindings/matlab 
-<code> + 
-git clone https://github.com/analogdevicesinc/libm2k-matlab.git +Next, update the locations of the [[https://github.com/analogdevicesinc/libm2k-matlab/blob/master/build_library_linux64.m#L13|libm2k headers]] to point to where libm2k is build. On Ubuntu these may look similar to:
-</code> +
-Next, update the locations of the [[https://github.com/analogdevicesinc/libm2k-matlab/blob/master/build_library_linux64.m#L13|libm2k headers]] and the [[https://github.com/analogdevicesinc/libm2k-matlab/blob/master/build_library_linux64.m#L15|installed library]] itself in the build script. On Ubuntu these may look similar to:+
 <code> <code>
     includepath  = fullfile('/usr','local','include');     includepath  = fullfile('/usr','local','include');
     hppPath = fullfile('/usr','local','include','libm2k');     hppPath = fullfile('/usr','local','include','libm2k');
     libs = '/usr/local/lib/libm2k.so';     libs = '/usr/local/lib/libm2k.so';
 +
 </code> </code>
  
-The [[https://github.com/analogdevicesinc/libm2k-matlab/blob/master/definelibm2k_linux64.m#L15|library definition]] needs to be updated as well. On Ubuntu this will look similar to:+Next uncomment 
 <code> <code>
-libDef.Libraries '/usr/local/lib/libm2k.so';+ clibgen.generateLibraryDefinition(headers,... 
 +    'IncludePath', includepath,... 
 +    'Libraries', libs,... 
 +    'PackageName', myPkg,... 
 +    'Verbose',true,... 
 +    'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0"]) 
 + delete definelibm2k.mlx
 </code> </code>
  
-Once those edits are complete, the entire build process can be run with the builder scriptFrom MATLAB in the libm2k-matlab folder run:+This part should be commented at this point 
 +<code> 
 + % pkg = definelibm2k_linux64; 
 + % build(pkg); 
 +</code> 
 + 
 +Make sure "definelibm2k.m" does not exist. If exists remove it. 
 + 
 +Run "build_library_linux64.m" (on Linux) or "build_library_win64.m" (on Windows) 
 + 
 +Inside "definelibm2k.m" you will get an error for a "inputoutput" value replace it with "input" 
 + 
 +Inside "definelibm2k.m" uncomment all functions that you need and replace "<SHAPE>" with the right value  
 + 
 +Replace the content from "definelibm2k_linux64.m" (on Linux) or the content from "definelibm2k_win64.m" (on Windows) with the content from "definelibm2k.m"  
 + 
 +Comment 
 +<code>  
 + clibgen.generateLibraryDefinition(headers,... 
 +    'IncludePath', includepath,... 
 +    'Libraries', libs,... 
 +    'PackageName', myPkg,... 
 +    'Verbose',true,... 
 +    'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0"]) 
 + delete definelibm2k.mlx 
 +</code> 
 +If on Liux unomment 
 +<code> 
 + pkg = definelibm2k_win64; 
 + build(pkg); 
 +</code> 
 + 
 +If on Windows unomment  
 +<code> 
 + pkg = definelibm2k_linux64; 
 + build(pkg); 
 +</code> 
 + 
 +Run "build_library_linux64.m" ( on Linux ) or "build_library_win64.m" ( on Windows ) 
 <code> <code>
 >> builder >> builder
Line 126: Line 170:
 ====== Support ====== ====== Support ======
  
-For support questions please post them on EngineerZone under the [[https://ez.analog.com/adieducation/university-program|Virtual Classroom Forum]].+For support questions please post them on EngineerZone under the [[ez>adieducation/university-program|Virtual Classroom Forum]].
  
 If you find any bugs please report them on the [[https://github.com/analogdevicesinc/libm2k/issues|libm2k issues tracker on GitHub]]. If you find any bugs please report them on the [[https://github.com/analogdevicesinc/libm2k/issues|libm2k issues tracker on GitHub]].
  
university/tools/m2k/matlab.txt · Last modified: 11 May 2023 12:57 by Ionut Muthi