c ++编译错误 - 未定义的引用

时间:2015-07-11 12:18:29

标签: c++ octave scilab

我的cpp文件包含ScilabOctave个头文件。我尝试使用此命令进行编译

g++ -l:/usr/lib/scilab/libscilab.so -L/usr/lib/scilab -L/usr/lib/scilab -I/usr/include/octave-3.8.1 -I/usr/include/octave-3.8.1/octave -I/usr/include/scilab s_o_test_v4.cpp -o s_o_test_v4

我收到以下错误

s_o_test_v4.cpp:(.text+0x5f4): undefined reference to `pvApiCtx'
s_o_test_v4.cpp:(.text+0x5ff): undefined reference to `isVarMatrixType'
s_o_test_v4.cpp:(.text+0x61a): undefined reference to `pvApiCtx'
s_o_test_v4.cpp:(.text+0x644): undefined reference to `getMatrixOfDouble'
s_o_test_v4.cpp:(.text+0x743): undefined reference to `string_vector::c_str_vec() const'
s_o_test_v4.cpp:(.text+0x755): undefined reference to `octave_main'
s_o_test_v4.cpp:(.text+0x7a2): undefined reference to `octave_value::octave_value(double)'
s_o_test_v4.cpp:(.text+0x847): undefined reference to `feval(std::string const&, octave_value_list const&, int)'
s_o_test_v4.cpp:(.text+0x8a3): undefined reference to `pvApiCtx'

Scilab和Octave函数都显示错误。我应该在编译命令中包含或删除某些内容吗?

1 个答案:

答案 0 :(得分:0)

也许你的make命令的顺序是错误的,另见 this SO question

  

请注意,需要在命令中指定库   在需要它们的文件后排队

这会使你的命令:

g++ -I/usr/include/octave-3.8.1 -I/usr/include/octave-3.8.1/octave -I/usr/include/scilab s_o_test_v4.cpp -o s_o_test_v4 -l:/usr/lib/scilab/libscilab.so -L/usr/lib/scilab -L/usr/lib/scilab