我试图将一些Visa代码包含到我的mex文件中,但是我找不出为什么函数没有被解析。代码和matlab输出如下所示。有没有人知道我做错了什么?干杯
eac
SourceFile:
#include "mex.h"
#include <stdio.h> /* For printf(). */
#include <string.h> /* For strcpy(), strcat(). */
#include <time.h> /* For clock(). */
#include "visa.h" /* Agilent VISA routines. */
#define VISA_ADDRESS "USB0::0x0957::0x17A6::MY51136169::0::INSTR"
#define IEEEBLOCK_SPACE 5000000
ViSession defaultRM, vi;
void do_command(char *command); /* Send command. */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {
do_command("*RST");
}
void do_command(command)
char *command;
{
char message[80];
strcpy(message, command);
strcat(message, "\n");
viPrintf(vi, message);
}Matlab输出:
>> mex HelloWorld.c -Lvisa32.lib
Writing library for HelloWorld.mexw32
c:\users\pehrlich\appdata\local\temp\mex_c04c6da5-c5ef-49d8-a8aa-c5107c66b1fa\helloworld.obj .text: undefined reference to '_viPrintf'
D:\MATLAB\R2006B\BIN\MEX.PL: Error: Link of 'HelloWorld.mexw32' failed.
??? Error using ==> mex
Unable to complete successfully.发布于 2011-12-22 22:41:03
您没有对mex使用正确的标志。
而不是告诉mex在哪里查找库:
>> mex HelloWorld.c -Lvisa32.lib告诉它使用what库(注意小写):
>> mex HelloWorld.c -lvisa32.libhttps://stackoverflow.com/questions/8604856
复制相似问题