gpt4 book ai didi

c - Mex 链接 visa32.lib

转载 作者:太空宇宙 更新时间:2023-11-04 07:36:17 25 4
gpt4 key购买 nike

我正在尝试将一些 Visa 代码包含到我的 mex 文件中,但无法弄清楚为什么这些函数没有解析。代码和 matlab 输出如下所示。有人暗示我做错了什么吗?干杯

电子书

源文件:

#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.

最佳答案

您没有对 mex 使用正确的标志。

与其告诉 mex 在哪里 寻找库:

>> mex HelloWorld.c -Lvisa32.lib

告诉它要使用什么库(注意小写):

>> mex HelloWorld.c -lvisa32.lib

关于c - Mex 链接 visa32.lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8604856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com