### Matlab external lib and mat functions

Posted:

**10 Mar 2011, 07:57**Hi,

as promised in my precedent post, here is my new question. I would like to import data from a matfile into BCI2000. For this purpose I use the matlab extlib provided with BCI2000. I thus included in the CMakeList corresponding to my module the following line:

BCI2000_USE( "MATLAB" )

It helped me to get rid of compilation errors but I still have the following linkage errors:

Linking CXX executable C:\Coding\BCI2000\prog\EmoPlaySignalProcessing.exe

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x4b): undefined reference to `matOpen'

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x65): undefined reference to `matGetVariable'

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x8d): undefined reference to `matClose'

collect2: ld returned 1 exit status

Are the lib present in the matlab directory only compiled for Borland ?

I am using mingw32 in association with CodeBlocks under windows 7 and with BCI2000 V3.0.

Also I do not know if this is related but I got that message when trying to use the matlab signal processing module:

MatlabFilter::Constructor: Could not load library libeng

Guillaume

------ Some things I did so far

Here are a few things that solved the situation but I would like your opinion on it and especially how to make it nicer.

1. change the matlab lib files that are in the extlib/matlab folder by those in my own matlab folder compiled with ld (the BCI2000 files where not recognized by mingw32),

2. rename the files "libxxx.lib" in the extlib/matlab folder to "xxx.lib" since for some reason all the lib annotations are removed by the cmake compilation (this one took me a long time to find),

3. change the cmake/extlib/Matlab.cmake file to include:

# Define the library directory

SET( LIBDIR_EXTLIB_MATLAB ${BCI2000_SRC_DIR}/extlib/matlab )

# Set the name of the library to link against within LIBDIR

SET( LIBS_EXTLIB_MATLAB mat.lib )

4. change the cmake/SetupExtLibDependencies.cmake to add at the proper position:

LINK_DIRECTORIES( ${LIBDIR_EXTLIB_MATLAB} )

SET( ${LIBRARIES}

${${LIBRARIES}}

${LIBS_EXTLIB_MATLAB}

)

that worked and I guess that some other needed lib can be added in the same way. I did not tried to recompile the whole BCI2000 to check if the "MatlabFilter::Constructor: Could not load library libeng" error disapears (if I add the libeng lib of course).

Please any comments are welcome or other / better solutions !

as promised in my precedent post, here is my new question. I would like to import data from a matfile into BCI2000. For this purpose I use the matlab extlib provided with BCI2000. I thus included in the CMakeList corresponding to my module the following line:

BCI2000_USE( "MATLAB" )

It helped me to get rid of compilation errors but I still have the following linkage errors:

Linking CXX executable C:\Coding\BCI2000\prog\EmoPlaySignalProcessing.exe

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x4b): undefined reference to `matOpen'

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x65): undefined reference to `matGetVariable'

CMakeFiles\EmoPlaySignalProcessing.dir/objects.a(EmoPlayFilter.cpp.obj):EmoPlayFilter.cpp:(.text+0x8d): undefined reference to `matClose'

collect2: ld returned 1 exit status

Are the lib present in the matlab directory only compiled for Borland ?

I am using mingw32 in association with CodeBlocks under windows 7 and with BCI2000 V3.0.

Also I do not know if this is related but I got that message when trying to use the matlab signal processing module:

MatlabFilter::Constructor: Could not load library libeng

Guillaume

------ Some things I did so far

Here are a few things that solved the situation but I would like your opinion on it and especially how to make it nicer.

1. change the matlab lib files that are in the extlib/matlab folder by those in my own matlab folder compiled with ld (the BCI2000 files where not recognized by mingw32),

2. rename the files "libxxx.lib" in the extlib/matlab folder to "xxx.lib" since for some reason all the lib annotations are removed by the cmake compilation (this one took me a long time to find),

3. change the cmake/extlib/Matlab.cmake file to include:

# Define the library directory

SET( LIBDIR_EXTLIB_MATLAB ${BCI2000_SRC_DIR}/extlib/matlab )

# Set the name of the library to link against within LIBDIR

SET( LIBS_EXTLIB_MATLAB mat.lib )

4. change the cmake/SetupExtLibDependencies.cmake to add at the proper position:

LINK_DIRECTORIES( ${LIBDIR_EXTLIB_MATLAB} )

SET( ${LIBRARIES}

${${LIBRARIES}}

${LIBS_EXTLIB_MATLAB}

)

that worked and I guess that some other needed lib can be added in the same way. I did not tried to recompile the whole BCI2000 to check if the "MatlabFilter::Constructor: Could not load library libeng" error disapears (if I add the libeng lib of course).

Please any comments are welcome or other / better solutions !