Using Octave in C ++
I'm new to Octave and C ++! I want to use Octave in C ++ and found this webpage . I started from the top code and tried to run it. Unfortunately, there is no document on this and I ran into a lot of errors. I was using msvc 2010 for the first time and found that I have to use gcc !! Here's what I've done so far:
- Download Octave from this link , (I download octave-4.0.0_0.zip)
-
I tried to compile this code:
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; }
I also included: 1) iostream and 2) octave directory: N: \ octave-4.0.0 \ include \ octave-4.0.0 \ octave \ oct.h
I got this error in msvc10: 1> n: \ octave-4.0.0 \ include \ math.h (169): error C2065: ' asm ': undeclared id 1> n: \ octave-4.0.0 \ include \ math .h (169): error C2146: syntax error: missing ';' before volatile identifier 1> n: \ octave-4.0.0 \ include \ math.h (169): error C2143: syntax error: missing ')' before ':' 1> n: \ octave-4.0.0 \ include \ math.h (169): error C2059: syntax error: ')'
and this error in codeblocks using gcc:
C: / Users / Sam / Documents / codeblock_C ++ / testOctave / main.cpp: 19: undefined reference to
operator<<(std::ostream&, Matrix const&)' obj\Debug\main.o: In function
ZN10dim_vector11make_uniqueEv ': N: /octave-4.0.0/include/octave-4.0.0/octave/dim-vector. h: 134: undefined reference to__sync_add_and_fetch_4' obj\Debug\main.o: In function
ZN10dim_vectorD1Ev ': N: /octave-4.0.0/include/octave-4.0.0/octave/dim-vector.h: 286: undefined reference to__sync_add_and_fetch_4' obj\Debug\main.o: In function
ZN15octave_refcountIiEmmEv': N: /octave-4.0. 0 / include / octave-4.0.0 / octave / oct-refcount.h: 72: undefined reference to__sync_add_and_fetch_4' obj\Debug\main.o: In function
ZN5ArrayIdEC2ERK10dim_vector ': N: /octave-4.0.0/include/octave-4.0.0/octave/Array.h: 184 : undefined reference todim_vector::safe_numel() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV6Matrix[__ZTV6Matrix]+0x10): undefined reference to
Array :: resize_fill_value () const 'obj \ Debug \ main.o: main.cpp :(. rdata $ _ZTV7NDArray [__ ZTV7NDArray] + 0x10): undefined reference toArray<double>::resize_fill_value() const' obj\Debug\main.o:main.cpp:(.rdata$_ZTV6MArrayIdE[__ZTV6MArrayIdE]+0x10): undefined reference to
Array :: resize_fill_value () const 'obj \ Debug \ main.o: main.cpp :(. Rdata $ _ZTV5ArrayIdE [__ ZTV5ArrayIdE] + 0x10): undefined reference to `Array :: resize_fill_value () const' collect2.exe: error : ld returned 1 exit status Process finished with status 1 (0 minute, 1 second)
I really appreciate any help!
source to share
No one has answered this question yet
See similar questions:
or similar: