【发布时间】:2018-10-18 20:44:26
【问题描述】:
我是 Octave 和 C++ 的新手!我想在 C++ 中使用 Octave 并找到了这个webpage。我从上面的代码开始并尝试运行它。不幸的是,没有关于这个问题的文件,我遇到了很多错误。我第一次使用msvc 2010,发现我应该使用gcc!以下是我到目前为止所做的:
- 从link 下载 Octave,(我下载 octave-4.0.0_0.zip)
-
我试图编译这段代码:
int main (void) { std::cout << "Hello Octave world!\n"; int n = 2; Matrix a_matrix = Matrix (n, n); for (octave_idx_type i = 0; i < n; i++) for (octave_idx_type j = 0; j < n; j++) a_matrix(i,j) = (i + 1) * 10 + (j + 1); std::cout << a_matrix; return 0; }
我还包括:1) iostream 和 2) octave 目录:N:\octave-4.0.0\include\octave-4.0.0\octave\oct.h
我在 msvc10 中收到此错误: 1>n:\octave-4.0.0\include\math.h(169): 错误 C2065: 'asm' : 未声明的标识符 1>n:\octave-4.0.0\include\math.h(169): 错误 C2146: 语法错误: 缺少';'在标识符“volatile”之前 1>n:\octave-4.0.0\include\math.h(169): 错误 C2143: 语法错误: 在 ':' 之前缺少 ')' 1>n:\octave-4.0.0\include\math.h(169): 错误 C2059: 语法错误: ')'
以及使用 gcc 的代码块中的此错误:
C:/Users/Sam/Documents/codeblock_C++/testOctave/main.cpp:19: 未定义引用
operator<<(std::ostream&, Matrix const&)' obj\Debug\main.o: In functionZN10dim_vector11make_uniqueEv': N:/octave-4.0.0/include/octave-4.0.0/octave/dim-vector.h:134: 未定义引用__sync_add_and_fetch_4' obj\Debug\main.o: In functionZN10dim_vectorD1Ev': N:/octave-4.0.0/include/octave-4.0.0/octave/dim-vector.h:286: 未定义引用__sync_add_and_fetch_4' obj\Debug\main.o: In functionZN15octave_refcountIiEmmEv': N:/octave-4.0.0/include/octave-4.0.0/octave/oct-refcount.h:72: 未定义引用__sync_add_and_fetch_4' obj\Debug\main.o: In functionZN5ArrayIdEC2ERK10dim_vector': N:/octave-4.0.0/include/octave-4.0.0/octave/Array.h:184: 未定义引用dim_vector::safe_numel() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV6Matrix[__ZTV6Matrix]+0x10): undefined reference toArray::resize_fill_value() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV7NDArray[__ZTV7NDArray]+0x10): 未定义引用Array<double>::resize_fill_value() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV6MArrayIdE[__ZTV6MArrayIdE]+0x10): undefined reference toArray::resize_fill_value() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV5ArrayIdE[__ZTV5ArrayIdE]+0x10): undefined reference to `Array::resize_fill_value() const' collect2.exe:错误:ld 返回 1 退出状态 进程以状态 1 终止(0 分钟,1 秒)
非常感谢任何帮助!
【问题讨论】:
-
如果可以,不如先在Linux上试试?
-
我也有 Ubuntu,你知道我如何在 Ubuntu 中做到这一点吗?
-
我知道它的旧线程,但我在使用 Visual Studio 2013 编译时也遇到了同样的错误。有人有任何线索吗?
-
我已经尝试使用 MinGW 和 Cygwin 进行编译 - 在 dim_vector 和 Array 区域中仍然出现“未定义的引用...”错误。有人对此有所了解吗?