- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是一位经验丰富的 C/C++ 开发人员,但在处理 Octave 中的 MEX 时,我非常新手。我确定我在这里遗漏了一些基本的东西,但我找不到它是什么。
这些是我的文件:
myhello.cpp
test.cpp
test.h
文件内容如下
(myhello.cpp):
#include "test.h"
#include "mex.h"
using namespace test;
void
mexFunction (int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
mexPrintf ("Hello, World!\n");
testMethod();
mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs);
}
(测试.h)
namespace test
{
void testMethod();
}
(测试.cpp)
#include "test.h"
#include <iostream>
using namespace std;
using namespace test;
void testMethod()
{
cout << "this works." << endl;
}
然后我通过 ./run-octave --no-gui 启动 Octave 4.0.0,并在提示符处键入以下内容:
mex -v myhello.cpp test.cpp
我得到的响应是:
g++ -c -fPIC -I/usr/local/include/octave-4.0.0/octave/.. -I/usr/local/include/octave-4.0.0/octave -I/usr/local/include -pthread -fopenmp -g -O2 -I. myhello.cpp -o myhello.o g++ -c -fPIC -I/usr/local/include/octave-4.0.0/octave/.. -I/usr/local/include/octave-4.0.0/octave -I/usr/local/include -pthread -fopenmp -g -O2 -I. test.cpp -o test.o g++ -shared -Wl,-Bsymbolic -o myhello.mex myhello.o test.o -L/usr/local/lib/octave/4.0.0 -L/usr/local/lib -loctinterp -loctave
我再次收到提示。
我输入
myhello(1,2,3)
然后得到这个:
error: /home/brush/Documents/mex_tests/myhello.mex: failed to load: /home/brush/Documents/mex_tests/myhello.mex: undefined symbol: _ZN4test10testMethodEv
很明显有些东西没有正确链接,但我不知道如何让一切都这样做。抱歉,我已经搜索了一段时间,但没有找到任何可以解决这个简单问题的方法。
提前致谢,本
附言我的系统是 Ubuntu 15.04,64 位。
最佳答案
除非我在 namespace test
中定义 void testMethod()
,否则我什至无法在 VS2013 中编译(实际上是链接)。这有效:
//test.cpp
#include "test.h"
#include <iostream>
using namespace std;
namespace test
{
void testMethod()
{
cout << "this works." << endl;
}
}
没有namespace test{ ... }
,有未解析的符号:
myhello.obj : error LNK2019: unresolved external symbol "void __cdecl test::testMethod(void)"
当它工作时,我得到:
>> myhello
Hello, World!
I have 0 inputs and 0 outputs
关于c++ - 初学者应对 Octave 音阶和 mex 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31213178/
假设我们在 Octave 中运行以下命令集: pkg load symbolic %loads the symbolic math package syms x y %declare x and y
Octave中vec的逆运算是什么? 例如。如果我需要将12x1向量转换成3x4矩阵,该怎么办? 最佳答案 我不知道Octave,但我认为您正在寻找 reshape 。 — Built-in Func
我试图在向量中找到一个字符串。 例如:query = "ab"in vector = ["ab", "cd", "abc", "cab"] 问题是:当我使用函数 strfind(vector,quer
对于练习,我必须以 Octave 为单位创建函数 x^i 从 i=1 到 i=10 的动画图。绘图必须有一个动态的标题,曲线的颜色必须改变。目前我的代码如下: function exercicequa
有没有一种方法可以让 Octave 矩阵将字符串和数字放在一起? 我想要一个休闲类型的矩阵: A=["A","B","C","D";1,2,3,4;2,3,4,5;3,4,5,6;4,5,6,7];
事实上,我已经为此奋斗了大约两个月。是什么让这些有所不同? hypotheses= X * theta temp=(hypotheses-y)' temp=X(:,1) * temp temp=tem
我想在我的绘图中添加带有注释的文本或图例框。 目前我的图例绘制在东北外,我想将新的图例(或文本框)添加到东南外的位置。 谢谢! 最佳答案 缺乏有关您的案例的更多信息: 据我所知,一个坐标区对象只能有一
我想在我的绘图中添加带有注释的文本或图例框。 目前我的图例绘制在东北外,我想将新的图例(或文本框)添加到东南外的位置。 谢谢! 最佳答案 缺乏有关您的案例的更多信息: 据我所知,一个坐标区对象只能有一
我想在 Octave 中执行整数除法(我使用的是最新版本 5.1.0)。我厌倦了 idivide(5, 2, "round") 应该产生 3。 Documentation表示将 idivide 与 r
我正在尝试从矩阵中按行获取最大索引。为此,我正在做: [throwaway, indexes] = max(blah, [], 2); 变量“throwaway”会存储我不再需要且永远不会使用的值,我
我在启动 Octave 后收到以下警告。我使用了来自 here 的安装说明. 可能是什么问题?这些是主要警告吗?我正在使用 Windows。 warning: gmsh does not seem t
我一直在学习机器学习类(class),目前学习分类。我实现了分类算法并获得了参数和成本。该作业已经具有绘制决策边界的功能并且可以正常工作,但我试图阅读他们的代码但无法理解这些行。 plot_x = [
我正在尝试更改 octave 中的polar 图中标记的外观。 r = rand(1,10); % the radius t = 30*rand(1,10); % the angles polar(t
我正在尝试从 Octave 中的文件读取矩阵,但我找不到解决方案。 输入文件是: 4 1 4 2 3 1 4 2 1 4 2 1 4 1 2 1 3 其中 4 是行数和列数。我希望能够将该信息存储在矩
我正在运行 Octave 3.4.0 并想创建一个透明的曲面图。但是,我在处理 facealpha 时无法这样做。 , edgealpha , alphadata和 alphadatamapping
安装一个包后,查找该包中有哪些功能的命令是什么? 例如,我有 control安装包。但是如何找到关于这个包的帮助,比如它包含哪些函数等等,就像使用 Matlab 一样? 是否必须去http://oct
我正在尝试在 Octave 音程终端中打印一长串数字。 disp(vec); 我得到的 7.0931e-01 6.2041e-05 9.7740e-01 9.9989e-01 8.8428e-01 9
我试图在OS X上安装Octave。执行brew install octave时,出现以下错误: octave: A LaTeX distribution is required to install
有人知道如何在 Octave 中增加图例字体大小吗? 最佳答案 这对我有用(kubuntu 9.04, Octave 3.2.2) print("plot.eps","-deps", "-F:30")
我试图弄清楚如何增加命令窗口文本。 我想出了legend: legend('{\fontsize{10} Low }', '{\fontsize{10} Medium }', '{\fontsize{
我是一名优秀的程序员,十分优秀!