loading
 
Mex on Matlab
Wenderson Soares from Brazil  [11 posts]
14 year
What probably is happening?


When i try to mex the mexfunction.cpp appear the follow error:

mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::close(void)" (?close@RR_API@@QAE_NXZ) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: void __thiscall RR_API::disconnect(void)" (?disconnect@RR_API@@QAEXXZ) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::setCameraProperties(char * *,int *,int *,int)" (?setCameraProperties@RR_API@@QAE_NPAPADPAH1H@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::getCameraProperties(char * *,int *,int *,int *,int *,int)" (?getCameraProperties@RR_API@@QAE_NPAPADPAH111H@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::setCameraFormat(int,int,int,char * const)" (?setCameraFormat@RR_API@@QAE_NHHHQAD@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::getCameraFormat(int *,int *,int *,char * const)" (?getCameraFormat@RR_API@@QAE_NPAH00QAD@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::positionWindow(int,int,int,int)" (?positionWindow@RR_API@@QAE_NHHHH@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::resizeWindow(int,int)" (?resizeWindow@RR_API@@QAE_NHH@Z) referenced in function _mexFunction
mexfunction.obj : error LNK2019: unresolved external symbol "public: bool __thiscall RR_API::moveWindow(int,int)" (?moveWindow@RR_API@@QAE_NHH@Z) referenced in function _mexFunction

 
Anonymous 14 year
Wenderson,

this is a basic compiler error saying that syntactically your program is ok BUT it cannot find the RoboRealm routines that you are using in your program. This is most likely due to your compiler not knowing that it needs to include the RR_API.cpp during the compilation. You may try to directly use

#include "RR_API.cpp"

inside MexFunction.cpp at the top and see if that helps.

STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
Steve, I did what u said, but is occuring the same error.
Anonymous 14 year
Perhaps you can zip up everything in the mex folder to include it in this forum and we can try to compile things on our side ... we replicated your error and solved it by doing the include. Most likely it is something minor which we don't know as we don't have your code to examine.

STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
Here is the files that i'm using to make the mex and api.......
I'm using matlab7 and visual basic 9.0
API.zip
Anonymous 14 year
Can you verify that these are the right files? We realize that the files are mostly from our API.zip download but your MexFunction.cpp begins with

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mex.h"
#include "RR_API.h"

which had you added the include reference above it would be

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mex.h"
#include "RR_API.cpp"

Note the .h change to .cpp

Because when you make this change your file compiles just fine..

Thanks,
STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
I dont know if is my compiler, but when i put RR_api.cpp stead of *.h, the compile appear the same error..

When you tried to mex there, everything occured right????

which degugger are you using?
Anonymous 14 year
Try an experiment and use

#include "does_not_exit.cpp"

and ensure that you get an error on that line. Perhaps you are not compiling the same file as you are editing.

We are using the same MS compiler/debugger.

You can also try using the .dsw file included in that folder and load it directly into visual studio and see if you can compile it from that point of view.

STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
First at all, I`ll start again......... so

When i used the line #include "does_not_exit.cpp" , appeared a error on compile, taking off this line the error is about:
" Error    1    error C2065: 'mwSize' : undeclared identifier    c:\users\wenderson\downloads\api2\api\matlab\mexfunction.cpp    127    Matlab"


It seems that a library is missing, but I dont see that, so i putted on the top of the code the lines:
#ifndef mwSize
#define mwSize int
#endif


And the compile stop to appear error, but when i debug the file appear the first error that i sent to you, even with RR_API.cpp stead of RR_API.h


Can be some problem of configuration??? or maybe my version of Matlab (matlab7.0.0)

Do you see some solution???


Thanks a lot
Wenderson Soares from Brazil  [11 posts] 14 year
And I`m trying to use the same example of http://www.roborealm.com/help/API.php

I just wanna comunicate Matlab with Roborealm.... just it...
Anonymous 14 year
Yea, def seems like your Matlab is not configured correctly for compiling.

Two options:
1. Why are you trying to compile the MexFunction in the first place? Do you need to make any changes to it? Or did the precompiled .mex not work with your version of Matlab?

2. You can try using Visual Studio to compile the mex function outside of Matlab. That may provide more standard ways of changing linking configurations.

Have you been able to compile any mex file using your Matlab? Perhaps start with the basic examples they provide and see if that even works?

STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
I had tried compile the same project with borland`s compiler, it works just for RR_API.cpp, but not to MexFunction.cpp, appeard an error that Mwsize is undefined.(maybe to be a old compiler 5.5)


And I tried to compile a file "yprime.c", when i compile from matlab`s compile or borlands, it works, but with VS 9.0 unfortantly not... and appear this error...

Creating library _lib3989.x and object _lib3989.exp

  C:\MATLAB7\BIN\WIN32\MEX.PL: Error: Link of 'yprime./out:yprime' failed.

so probabily the errors are on the VS 9.0 configurations, but i configurated everthing there...... and I don`t know why is happening this
Anonymous 14 year
1. Why are you trying to compile the MexFunction in the first place? Do you need to make any changes to it? Or did the precompiled .mex not work with your version of Matlab?

STeven.
Wenderson Soares from Brazil  [11 posts] 14 year
The precompiled .mex dont work......... probabily because de configuration of meu VS 9.0.

I tried this to help my configuration.....
http://www.mathworks.fr/matlabcentral/fileexchange/18508

And I also tried this to help the to set up...

http://www.mathworks.fr/matlabcentral/fileexchange/22689-microsoft-3264-bit-visual-c-2008-express-support-files

Anonymous 14 year
I assume none of those postings helped?

Lets try another route. Is your Matlab version capable of executing Java? I.e. try the next two lines in the Command Window and see if it prints "Hello World". If it does we can probably create a version of RoboRealm.dll in this way that would be executed directly using Matlab without any compilation needed. The speed would be slower but perhaps that is not a concern for you?

import java.lang.*
System.out.println('Hello World')

Let us know if that works.
STeven.

Wenderson Soares from Brazil  [11 posts] 14 year
Yes, my matlab verison is capable of exacution Java,  when I use the command:

import java.lang.*
System.out.println('Hello World')

The answer was Hello World
Anonymous 14 year
Go ahead and download the API.zip file again. We've changed the RR_API.class in the Java folder to be compatible with Matlab. You will also see a new test_java.m file in the Matlab folder. Try to execute that one.

Note that you will need to change the javaaddpath in the test_java.m to point to where you have unzipped the RR_API.class file in order for this to work.

What error do you get when you try to run the precompiled mex version?

STeven.
Anonymous 14 year
I installed the new version of matlab, and when i compile with the java script or with visual studio, apear the same error.


??? Invalid MEX-file 'C:\Users\Wenderson\Documents\MATLAB\RR_API.mexw32':
C:\Users\Wenderson\Documents\MATLAB\RR_API.mexw32 is not a valid Win32 application.

and i tried also use the version 64bits, and apeard this:

??? Invalid MEX-file 'C:\Users\Wenderson\Documents\MATLAB\RR_API.mexw64':
C:\Users\Wenderson\Documents\MATLAB\RR_API.mexw64 is not a valid Win32 application.
Anonymous 14 year
and when i just tried the methods before appear...

LINK : error LNK2001: unresolved external symbol mexFunction
C:\USERS\WENDER~1\APPDATA\LOCAL\TEMP\MEX_CE~1\templib.x : fatal error LNK1120: 1 unresolved externals

  C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Link of 'rr_api.mexw64' failed.


Is appear to be a link problem with the lib

Do you know something about it????
Wenderson Soares from Brazil  [11 posts] 14 year
using the java i forgot to write the warning...

Warning: Could not find an exact (case-sensitive) match for 'RR_API'.
C:\Users\Wenderson\Documents\MATLAB\rr_api.mexw64 is a case-insensitive match and will be
used instead.
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
warning('off','MATLAB:dispatcher:InexactCaseMatch').
This warning will become an error in future releases.
> In test_java at 5
??? Invalid MEX-file 'C:\Users\Wenderson\Documents\MATLAB\rr_api.mexw64':
C:\Users\Wenderson\Documents\MATLAB\rr_api.mexw64 is not a valid Win32 application.

.

Error in ==> test_java at 5
rr = RR_API();
Anonymous 14 year
Wenderson,

I think we have reached the limit of our Matlab knowledge. Perhaps you will need to take these issues up with MathWorks as they probably have better knowledge of compilation errors against Matlab. At this point it does not appear to be a RR related issue unless you can offer some more information?

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index