[英]Use Octave in msvc 2010
I am using Octave within MSVC 2010. First I downloaded Octave latest version at this link . 我在MSVC 2010中使用Octave。首先,我通过此链接下载了Octave最新版本。 After installing, I tried to run this simple code:
安装后,我尝试运行以下简单代码:
#include <iostream>
#include<octave-3.6.4\octave\oct.h>
#include<octave-3.6.4\octave\config.h>
#include<octave-3.6.4\octave\octave.h>
using namespace std;
int main (void)
{
std::cout << "Hello Octave world!\n";
system("PAUSE");
return 0;
}
Note that I added these links to my project as well: 请注意,我也将这些链接添加到了我的项目中:
First, I got this error that it cannot find math.h in Program Files while this file was in my Program Files (x86). 首先,我收到一个错误消息,当该文件位于我的程序文件(x86)中时,它无法在程序文件中找到math.h。 So, I changed it to: C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include\\math.h and it solved this error.
因此,我将其更改为:C:\\ Program Files(x86)\\ Microsoft Visual Studio 10.0 \\ VC \\ include \\ math.h,它解决了此错误。 However, now I get this error:
但是,现在出现此错误:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall octave_value::~octave_value(void)" (__imp_??1octave_value@@QAE@XZ) referenced in function "public: void * __thiscall octave_value::`vector deleting destructor'(unsigned int)" (??_Eoctave_value@@QAEPAXI@Z)
It is not sufficient to add the library path to the project. 仅将库路径添加到项目中是不够的。
You have to add the library name(s) (including .lib
) to the "Additional Dependencies" in the Linker/Input tab. 您必须将库名称(包括
.lib
)添加到“链接器/输入”选项卡中的“其他依赖项”。
Edit 编辑
To verify what library has been searched you can enable the Linker/General/Show Progress option. 要验证已搜索的库,可以启用“链接器/常规/显示进度”选项。 Then you can see in the Build Output what library has actually be used in symbol search.
然后,您可以在Build Output中看到在符号搜索中实际使用了哪个库。
Edit 编辑
Your example code doesn't show any instance of an array of octave_value
instances. 您的示例代码未显示
octave_value
实例数组的octave_value
实例。 So it's a bit surprising that you need to link with any library with the code you've shown. 因此,您需要使用显示的代码与任何库链接,这有点令人惊讶。 But anyway you want to have these externals resolved.
但是无论如何,您都希望解决这些外部问题。
If there is no other resource (manual, ...) you should detect where the octave_value
class is implemented. 如果没有其他资源(手册,...),则应检测在哪里实现了
octave_value
类。 This can be a static library or a DLL. 这可以是静态库或DLL。
You can detect the DLL implementation with a dumpbin /exports
on the DLLs. 您可以使用DLL上的
dumpbin /exports
来检测DLL实现。 In that case you need the corresponding import libraries. 在这种情况下,您需要相应的导入库。 The LIB should have the same base name as the DLL.
LIB应该具有与DLL相同的基本名称。 Verify that you have added that dependency and how the linker searches this library for symbols.
验证您是否已添加该依赖性以及链接程序如何在此库中搜索符号。
The name of the symbols __imp_??1octave_value@@QAE@XZ
indicates that it should be in a DLL. 符号
__imp_??1octave_value@@QAE@XZ
表示它应该在DLL中。 But since you have a problem you might want to search LIBs too. 但是由于您有问题,您可能也要搜索LIB。 You can detect the LIB implementation with a
dumpbin /symbols
. 您可以使用
dumpbin /symbols
检测LIB实现。 In that case you have to add the LIB directly. 在这种情况下,您必须直接添加LIB。 Again verify it with the Build Output.
再次使用“构建输出”进行验证。
The dumpbin output will probably very verbose. dumpbin输出可能非常详细。 You should use either
findstr
to limit the output or redirect the output to a file and search the symbols with an editor of your choice. 您应该使用
findstr
来限制输出或将输出重定向到文件,然后使用您选择的编辑器搜索符号。
Search for ocatave_value
. 搜索
ocatave_value
。 If you find a different decoration of the constructor and destructor you might have missed to set an option. 如果您发现构造函数和析构函数的装饰不同,则可能会错过设置选项的机会。 A preprocessore directory could be used to define how the library is use.
预处理程序目录可用于定义库的使用方式。 Eg if you find
octave_value::octave_value
without the __imp_
prefix you have accidentily compiled for a DLL version altough the class is implemented in a static library. 例如,如果您发现不带
__imp_
前缀的octave_value::octave_value
,则意外地为DLL版本编译了该类,而该类是在静态库中实现的。 In that case, read the manual and ask at the octave mailing list forum or whatever. 在这种情况下,请阅读手册,并在八度邮件列表论坛中询问问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.