Urgent! compiling error on the code!


Hi all,

I am a junior user of opal kelly. I find some error when I compile the code in matlab, so that I hope that the error can be solved by yours kindly help.
I am using the Xilinx 3 XC3S400. The code is saved as function(fx) file (.m).

Undefined function or variable ‘matlab’.

Error in TOP (line 41)
loadlibrary(‘okFrontPanel’, sprintf(’%s\okFrontPanelDLL.h’, matlab));

parts of code:

calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Destruct’, fpga.ptr); % void port confiliction, otherwise the usb port and power supply should be re-pluged.
%clear all;
currentDir = pwd;
%add API references
APIpath_matlab = ‘C:\Program Files\Opal Kelly\FrontPanelUSB\API32\Matlab’;
APIpath = ‘C:\Program Files\Opal Kelly\FrontPanelUSB\API32’;

if ~libisloaded(‘okFrontPanel’)
%loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
loadlibrary(‘okFrontPanel’, sprintf(’%s\okFrontPanelDLL.h’, mtlab));

How can I solve this problem? I have already put the okFrontPanelDLL.h in the folder of the corresponding path.
It will be great that if anyone can solve this problem.



can anyone help me to solve this problem?


You have a Matlab error. Presumably

loadlibrary(‘okFrontPanel’, sprintf(’%s\okFrontPanelDLL.h’, matlab));

should be

loadlibrary(‘okFrontPanel’, sprintf(’%s\okFrontPanelDLL.h’, APIpath_matlab));

Another problem you might run into is Matlab treats the path like a stack - it checks the most recently added path folders first, and you are adding the general okFrontPanelDLL.h path after the Matlab-specific one. Therefore, in your commented-out loadlibrary call without a specific path, it looks to FrontPanelUSB\API32 first. You should reverse the order of your addpath() calls.

A last tip: the matlab function fullfile() treats path concatenation nicely: fullfile(APIpath_matlab, ‘okFrontPanelDLL.h’)