使用mex在Matlab中编译C ++失败

时间:2016-02-25 22:21:45

标签: c++ macos matlab zlib mex

(注意:细节已更新。)我正在尝试在我的机器上安装mYm(运行OS X 10.11.3的MacBook Pro 15)。下载了mYm后,我尝试使用mex in Matlab:

> 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 include和lib文件,但我不知道它们位于何处?我安装了XCode。

顺便说一下:

>> mex -setup
MEX configured to use 'Xcode with Clang' for C language compilation.

1 个答案:

答案 0 :(得分:0)

由于这是一个MySQL包装器,因此您很可能需要链接其库。

我还没有尝试过,但要引用readme.txt文件included

  

可以使用以下命令编译源代码:

mex -I[mysql_include_dir] -I[zlib_include_dir] -L[mysql_lib_dir] -L[zlib_lib_dir] -lz -lmysqlclient mym.cpp
     

(在Mac OS X上,您可能还需要-lSystemStubs开关以避免命名空间冲突)

     

注意:要编译,应在系统上安装zlib库   (包括标题)。