You are not logged in.
Hey,
I try to implement MEX function for udp transport using Matlab 2014a.
The problem that I encountered was that Microsoft Visual C++ 2010 Express is not supported by Matlab 2014a.
According to: http://www.mathworks.com/support/compilers/R2014a/
Unlike to other version, e.g. 2011: http://www.mathworks.com/support/compil … win32.html
Microsoft Visual C++ 2010 Express are supported in other version.
Can I use other Microsoft Visual C++ version instead of 2010?
If not, is there anyway that I can use Matlab 2014a to implement Mex function for udp transport?
Thanks!
Offline
We have only officially tested the MEX with the Microsoft Visual C++ 2010 Express on Windows.
However, the MEX C code should be able to be compiled in the later compilers. The code relies on the wsock32 and Kernel32 libraries in Windows. If you have a later compiler, you can try it yourself. We will be looking at what official version to support for Matlab 2014a in the near future.
If you get any errors with other compilers, please post them.
Offline
Hi Welsh,
I try to use Microsoft Visual C++ 2013 Professional.
I can set Microsoft Visual C++ 2013 professional as compiler, but when I run the command "which wl_mex_udp_transport".
For automatic compilation, The error message is "Error using wl_mex_udp_transport (line 144)
Please install "Microsoft Visual C++ 2010 Express" and re-run wl_mex_udp_transport. \nSee
http://warpproject.org/trac/wiki/WARPLab/MEX for more information".
For manual compilation, when I run "mex -g -O wl_mex_udp_transport.c -lwsock32 -lKernel32 -DWIN32 ", it gives me the error:
"Warning: MEX cannot find library 'wsock32'. Defaulting to 'libwsock32.lib'.
Warning: MEX cannot find library 'Kernel32'. Defaulting to 'libKernel32.lib'.
Building with 'Microsoft Visual C++ 2013 Professional (C)'.
Error using mex
LINK : fatal error LNK1104: cannot open file 'libwsock32.lib'"
It seems that I can't use compiler other than Microsoft Visual C++ 2010 Express.
Do you have any suggestions?
Offline
Have you installed the Windows SDK 7.1?
There is a basic how to compile MEX guide that we put together. See if following that fixes the problem.
Offline
Thanks for your reply.
I have installed Windows SDK 7.1.
From mex -setup, I can set the compiler to Windows SDK 7.1 or Visual C++ 2013 Professional.
If I set compiler as Windows SDK 7.1 instead of Visual C++ 2013 Professional.
For automatic and manual compilation, it still gives me the same error as before.
Offline
If you open Windows Explorer, can you find:
C:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64\WSock32.lib C:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64\Kernel32.lib
These are the two libraries that the MEX is trying to link against. One thing you can try is to specify library paths manually in the mex compile command. While in the M_Code_Reference/mex directory, run:
mex -g -O wl_mex_udp_transport.c '-LC:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64' -lwsock32 -lKernel32 -DWIN32
Offline
Another thing to look at is:
C:\Users\<your_user_name>\AppData\Roaming\MathWorks\MATLAB\R2011a\mexopts.bat
where <your_user_name> is your windows login username (or you can see where mexopts.bat is located when you run mex -setup).
If you look in the file, you can see the default search paths that MATLAB is using during the MEX compile. The "LIB" variable is the default library search path and needs to have a path containing WSock32.lib and Kernel32.lib in it. Otherwise, you will always have to manually specify the library path for the MEX compile.
Offline
According to http://www.mathworks.com/matlabcentral/ … onal-2013, mex function doesn't use bat files in Matlab 2014a.
Does this change has any impact on WARPLab MEX Compilation?
There is still some linkage problem in my case.
If I run "mex -g -O wl_mex_udp_transport.c '-LC:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64' -lwsock32 -lKernel32 -DWIN32", it works.
Then I run "wl_setup", the error is
"Undefined function 'inifile' for input arguments of type 'char'
adding path 'C:\Users\GNAN\Xilinx\WARPLab_Reference_Design_7.4.0\config'
Warning: Name is nonexistent or not a directory: C:\Users\GNAN\Xilinx\WARPLab_Reference_Design_7.4.0\config".
What should I do for this error?
Offline
If I run "mex -g -O wl_mex_udp_transport.c '-LC:\Program Files\Microsoft SDKs\Windows\v7.1\lib\x64' -lwsock32 -lKernel32 -DWIN32", it works.
Ok, great- thanks for posting this. We'll update the recommendations for compiling mex to include this variation.
What was your 'mex -setup' when this finally worked (i.e. which compiler was selected)?
Then I run "wl_setup", the error is
"Undefined function 'inifile' for input arguments of type 'char'
adding path 'C:\Users\GNAN\Xilinx\WARPLab_Reference_Design_7.4.0\config'
Warning: Name is nonexistent or not a directory: C:\Users\GNAN\Xilinx\WARPLab_Reference_Design_7.4.0\config".
What should I do for this error?
What is MATLAB's current working directory when you run wl_setup? You should first CD to the M_Code_Reference folder of the expanded reference design .zip archive, then run 'wl_setup' directly on the MATLAB command line.
Offline
Microsoft Visual C++ 2013 Professional was selected as compiler.
I run "wl_setup" in mex folder in M_Code_Reference folder.
In step 5), should I run "wl_setup" in M_Code_Reference folder?
1) Please familiarize yourself with the process at:
http://warpproject.org/trac/wiki/WARPLab/MEX
to make sure your environment is set up properly.
2) Set up mex to choose your compiler. (mex -setup)
1. Select "Yes" to have mex locate installed compilers
2. Select "Microsoft Visual C++ 2010 Express"
3. Select "Yes" to verify your selections
3) Change directory to M_Code_Reference/mex (cd mex)
4) Run the compile command:
mex -g -O wl_mex_udp_transport.c -lwsock32 -lKernel32 -DWIN32
5) Re-run wl_setup and make sure that "WARPLab Mex UDP" is an available transport.
Offline
Yes. wl_setup only lives in M_Code_Reference and does not get put in your MATLAB path. This was done so that when you run wl_setup, you know which version of WARPLab you are installing in to your MATLAB path (wl_setup removes other WARPLab installations from your MATLAB path).
The steps should really be:
5) Change directory back to M_Code_Reference (cd ..)
6) Re-run wl_setup and make sure that "WARPLab Mex UDP" is an available transport.
Offline
Thanks a lot!
I can use WARPLab with mex function right now.
Just want to remind, the mex -setup in 2014a is a little bit different.
To set the compiler, you can run "mex -setup" and directly click the compiler name from command window.
Or you can set compiler as Microsoft Visual C++ 2013 Professional by "mex -setup:C:\Users\GNAN\AppData\Roaming\MathWorks\MATLAB\R2014a\mex_C_win64.xml C"
Offline
Great to hear it's working. And thank you for providing the very good feedback. We (obviously) hadn't tried MATLAB 2014a yet. We'll make sure these new issues are addressed in the next WARPLab release.
Offline