0
(注意:詳細信息已更新。)我試圖在我的機器上安裝mYm(運行OS X 10.11.3的MacBook Pro 15)。編譯在Matlab使用MEX:在Matlab中使用mex編譯C++失敗
> mex -I/usr/local/mysql/include -L/usr/local/mysql/lib mym.cpp;
不過,我得到了下面的錯誤,我不能解析:
Building with 'Xcode Clang++'.
Error using mex
Undefined symbols for architecture x86_64:
"_compress", referenced from:
_mexFunction in mym.o
"_compressBound", referenced from:
_mexFunction in mym.o
"_mysql_affected_rows", referenced from:
_mexFunction in mym.o
"_mysql_close", referenced from:
_mexFunction in mym.o
"_mysql_data_seek", referenced from:
_mexFunction in mym.o
"_mysql_error", referenced from:
_mexFunction in mym.o
"_mysql_fetch_fields", referenced from:
_mexFunction in mym.o
"_mysql_fetch_lengths", referenced from:
_mexFunction in mym.o
"_mysql_fetch_row", referenced from:
_mexFunction in mym.o
"_mysql_field_count", referenced from:
_mexFunction in mym.o
"_mysql_free_result", referenced from:
_mexFunction in mym.o
"_mysql_get_client_info", referenced from:
_mexFunction in mym.o
"_mysql_get_host_info", referenced from:
_mexFunction in mym.o
"_mysql_get_server_info", referenced from:
_mexFunction in mym.o
"_mysql_init", referenced from:
_mexFunction in mym.o
"_mysql_num_fields", referenced from:
_mexFunction in mym.o
"_mysql_num_rows", referenced from:
_mexFunction in mym.o
"_mysql_ping", referenced from:
_mexFunction in mym.o
"_mysql_query", referenced from:
_mexFunction in mym.o
"_mysql_real_connect", referenced from:
_mexFunction in mym.o
"_mysql_real_escape_string", referenced from:
_mexFunction in mym.o
"_mysql_real_query", referenced from:
_mexFunction in mym.o
"_mysql_select_db", referenced from:
_mexFunction in mym.o
"_mysql_stat", referenced from:
_mexFunction in mym.o
"_mysql_store_result", referenced from:
_mexFunction in mym.o
"_uncompress", referenced from:
deserialize(char const*, unsigned long) in mym.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
任何人誰可以幫助您完成安裝嚮導告訴我,也包括zlib的包括和lib fil es,但我不知道他們在哪裏?我已安裝XCode。
順便說一句:
>> mex -setup
MEX configured to use 'Xcode with Clang' for C language compilation.
上面的代碼有兩個錯誤:首先你需要static_cast(長度),因爲你的編譯器不會從long到int的隱式轉換。第二個你需要#include 在mym.cpp中。最後,我認爲在C++模式下編譯mex代碼是沒有道理的,除非您知道如何在mex環境中使用C++對象,但我認爲您還沒有這樣做。 –
user3528438
到目前爲止,謝謝。我修復了編譯錯誤。請立即檢查更新的錯誤。 –
你錯過了很多庫。找到這些庫並將它們傳遞給mex並加上-l和-L – user3528438