From: Alejandro on
Hello, I had the same problem, the solution was to include a parameter to the compiler as follows:

g++ -Wl,-rpath,/usr/local/matlab/bin/glnx86

be sure to use your own matlab path.
this will tell the compiler to load all the libraries from the specified path.
good luck!

alex

"JAmes Bradley" <jamesbradley21(a)hotmail.com> wrote in message <h8nq2g$frv$1(a)fred.mathworks.com>...
> Hi,
>
> Im attempting to compile a small example program to connect to matlab from c. Im using the engdemo.c file as a starting point.
> My libs are in the location
> /opt/matlab/extern/include/
>
> with other paths being "normal" relaitive to that.
>
> Anyway with the compile line g++ -o engdemo.exe /opt/matlab/bin/glnxa64/libeng.so -I/opt/matlab/extern/include/ -L/opt/matlab/bin/glnxa64/
>
> I get returned a whole lot of errors?
>
> Any one any ideas.
>
> Help much appreciated.
>
> (And Ive tried adding rpath but either thats not the problem or ive not done it correctly.)
> James
>
> /usr/bin/ld: warning: libut.so, needed by /opt/matlab/bin/glnxa64/libeng.so, not found (try using -rpath or -rpath-link)
> /usr/bin/ld: warning: libmx.so, needed by /opt/matlab/bin/glnxa64/libeng.so, not found (try using -rpath or -rpath-link)
> /usr/bin/ld: warning: libmat.so, needed by /opt/matlab/bin/glnxa64/libeng.so, not found (try using -rpath or -rpath-link)
> /usr/bin/ld: warning: libhdf5.so.0, needed by /opt/matlab/bin/glnxa64/libmat.so, not found (try using -rpath or -rpath-link)
> /usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/crt1.o: In function `_start':
> (.text+0x20): undefined reference to `main'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Pcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_size'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Fopen'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_INT_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5check_version'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Rget_obj_type'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Awrite'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_member_type'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gunlink'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_INT64_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dget_space'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sselect_elements'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Rdereference'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_member_name'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sget_simple_extent_npoints'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5P_CLS_DATASET_CREATE_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Eset_auto'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gget_objinfo'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tlock'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tinsert'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_member_offset'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_SHORT_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dread'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Acreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gget_objname_by_idx'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_UCHAR_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tequal'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Pset_deflate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aget_space'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sget_simple_extent_ndims'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_UINT64_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tset_size'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Pset_userblock'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aget_type'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Fcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Eget_auto'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Rcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Pclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Screate_simple'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sselect_hyperslab'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_DOUBLE_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sget_simple_extent_dims'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dvlen_reclaim'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_C_S1_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tvlen_create'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5P_CLS_FILE_CREATE_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tset_overflow'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tcopy'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dget_type'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_sign'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Screate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_UINT_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_FLOAT_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_LONG_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aopen_name'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aread'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dopen'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_nmembers'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aget_num_attrs'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Sget_simple_extent_type'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5open'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Pset_chunk'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_STD_REF_OBJ_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aopen_idx'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_SCHAR_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gopen'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_overflow'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_USHORT_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dwrite'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Dclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tget_class'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Tcreate'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5T_NATIVE_ULONG_g'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Fclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gget_num_objs'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Gclose'
> /opt/matlab/bin/glnxa64/libmat.so: undefined reference to `H5Aget_name'