Hello! Help me please.I want to use Ogre3D in mex (for s-function). http://www.ogre3d.org/ But my .cpp file contains OGRE's include files which Matlab doesn't see. In Visual Studio it can be adjusted in properties of solution. http://s001.radikal.ru/i196/1104/e6/e04d2a5746f8.jpg Is it possible to make so in Matlab? I will be grateful for any answer.Thank you.

 채택된 답변

Jarrod Rivituso
Jarrod Rivituso 2011년 4월 2일

0 개 추천

When you use the mex function, you should be able to use the -I flag to specify the include directories.
Is that what you are looking for?

댓글 수: 5

Natalia
Natalia 2011년 4월 2일
May be I do something not correctly... But at me the following message
mex -l $(OGRE_HOME)\samples\include
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: '$(OGRE_HOME)\samples\include' not found.
??? Error using ==> mex at 208
Unable to complete successfully.
Jarrod Rivituso
Jarrod Rivituso 2011년 4월 2일
Hmm... can you try it without using the $OGRE_HOME? I wonder if that is your problem.
Note that you can access environment variables in MATLAB using the getenv function. For instance, getenv('path')
Natalia
Natalia 2011년 4월 2일
getenv ('C:\OgreSDK\samples\include')
ans =
''
mex -lC:\OgreSDK\samples\include
Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
Use the -help option for more information, or consult the MATLAB API Guide.
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: No file names given.
Jarrod Rivituso
Jarrod Rivituso 2011년 4월 2일
Hi Natalia,
You need to put both the include path and the source files. So, for instance...
mex -IC:\OgreSDK\samples\include mymexfile.c
Walter Roberson
Walter Roberson 2011년 4월 4일
getenv() requires the name of an environment variable as its input, such as
getenv('OGRE_HOME')
to verify that OGRE_HOME is set.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Natalia
Natalia 2011년 4월 2일

0 개 추천

I should do this operation for each folder? Or it is enough to add a folder which includes all the others?
In Visual Studio it looks:
Code
+ Configuration Properties
General
* Output Directory: $(OGRE_HOME)\bin\$(ConfigurationName)
* Intermediate Directory: $(OGRE_HOME)\obj\$(ConfigurationName)
Debugging
* Command: $(OGRE_HOME)\bin\$(ConfigurationName)\$(TargetFileName)
* Working Directory: $(OGRE_HOME)\bin\$(ConfigurationName)
C++
General
* Additional Include Directories: ..\include;$(OGRE_HOME)\include;$(OGRE_HOME)\samples\include
Linker
General
* Additional Library Directories: "$(OGRE_HOME)\lib"
Input
* Additional Dependencies: OgreMain_d.lib OIS_d.lib

댓글 수: 1

Jarrod Rivituso
Jarrod Rivituso 2011년 4월 2일
Yes, you will need to add each include path and the library directories. Use the -l and -L flags to add library paths (-l) and actual library files (-L).
Again, the documentation has a table of all supported compiler switches:
http://www.mathworks.com/help/techdoc/ref/mex.html

댓글을 달려면 로그인하십시오.

Natalia
Natalia 2011년 4월 2일

0 개 추천

mex -IC:\OgreSDK\samples\include ExampleApplication.h
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: 'ExampleApplication.h' not found.
??? Error using ==> mex at 208
Unable to complete successfully.
I do not understand why there is an error...
And if I have 1000 include files.... I should specify all of them? By the way, simstruc.h I shouldn't specify a file, is it mean there are default folders in matlab?

댓글 수: 3

Kaustubha Govind
Kaustubha Govind 2011년 4월 4일
You don't have to specify names of header files - the -I option is added for the _directory_ containing the header files. You need something like:
mex -IC:\OgreSDK\samples\include -IC:\OgreSDK\include -I"..\include" -LC:\OgreSDK\lib mymexfile.c -l OgreMain_d.lib -l OIS_d.lib
Yes, simstruc.h is in a MATLAB directory that is automatically included by MEX
Natalia
Natalia 2011년 4월 5일
Thank you! Your answers as always the most exact and clear for me :)
Kaustubha Govind
Kaustubha Govind 2011년 4월 5일
Glad to be of help. :)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Adding custom doc에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by