声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: dongjun1101

[混合编程] matlab7.0和C++的接口问题

[复制链接]
 楼主| 发表于 2007-4-28 14:14 | 显示全部楼层
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat
晕啊,最后一个问题了,这是嘛意思啊 :loveliness:
回复 支持 反对
分享到:

使用道具 举报

发表于 2007-4-28 14:15 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:14 发表
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat
晕啊,最后 ...


按照第二行英文的文件模版,修改第一行英文的文件
 楼主| 发表于 2007-4-28 14:17 | 显示全部楼层
我要是认识你就好了,疯了我了,是把那个文件贴到目标文件里,覆盖原来的吗
 楼主| 发表于 2007-4-28 14:19 | 显示全部楼层
:funk: D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat 我没有这个文件呢
发表于 2007-4-28 14:22 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:19 发表
:funk: D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat 我没有这个文件呢


你看清楚你给我的信息:


Warning: Mbuild requires that the Microsoft Visual C++ 6.0
directories "VC98" and "Common" be located within the same parent directory.
(Expected to find a directory named "Common" in the directory 'E:'.)
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\compopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mbuildopts\msvc60compp.bat

Warning: Mex requires that the Microsoft Visual C++ 6.0
directories "VC98" and "Common" be located within the same parent directory.
(Expected to find a directory named "Common" in the directory 'E:'.)
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mexopts\msvc60opts.bat

哪里提到 lccopts.bat 这个文件?

不宜用 LCC 的方式进行混合编程,所以在 mbuild 和 mex 的时候还是选择VC吧
 楼主| 发表于 2007-4-28 14:27 | 显示全部楼层
我再次mex -setup的时候就出现了 这个了啊
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat
第一次的确是msvc60opts.bat
这是为什么呢
发表于 2007-4-28 14:28 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:27 发表
我再次mex -setup的时候就出现了 这个了啊
Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0 ...


这是你的选择问题,一个是LCC方式,一个是VC方式

不宜用 LCC 的方式进行混合编程,所以在 mbuild 和 mex 的时候还是选择VC吧

评分

1

查看全部评分

 楼主| 发表于 2007-4-28 14:31 | 显示全部楼层
那你看看我一开始给你发的最长的那写程序,我选的都是VC啊,怎么会LCC呢,我哪步弄错了呢
发表于 2007-4-28 14:34 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:31 发表
那你看看我一开始给你发的最长的那写程序,我选的都是VC啊,怎么会LCC呢,我哪步弄错了呢


最长的那个是没错的,建议重新setup一次,选择VC的
 楼主| 发表于 2007-4-28 14:37 | 显示全部楼层
这个mbuild 和 mex 是只能做一次吗,再做就不对了

[ 本帖最后由 eight 于 2007-4-28 14:38 编辑 ]
发表于 2007-4-28 14:38 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:37 发表
这个mbuild 和 mex 是只能做一次吗,再做就不对了

不可能吧,再调用 mbuild -setup 和 mex -setup 不行吗?
 楼主| 发表于 2007-4-28 14:43 | 显示全部楼层
再次调的时候它选择的就只有LCC了mex -setup
Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc C version 2.4 in D:\MATLAB7.0\sys\lcc

[0] None

Compiler: 1

Please verify your choices:

Compiler: Lcc C 2.4
Location: D:\MATLAB7.0\sys\lcc

Are these correct?([y]/n): y

Try to update options file: C:\Documents and Settings\xiaowei\Application Data\MathWorks\MATLAB\R14\mexopts.bat
From template:              D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat

Done . . .

>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc C version 2.4 in D:\MATLAB7.0\sys\lcc

[0] None

Compiler: 0

  mbuild: No compiler selected. No action taken.

>>
>> mex -setup
Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers [y]/n? mbuild -setup

Select a compiler:
[1] Lcc C version 2.4 in D:\MATLAB7.0\sys\lcc

[0] None

Compiler: mbuild -setup
Please select from 0-1
Compiler:
这是一部分
发表于 2007-4-28 14:46 | 显示全部楼层
原帖由 dongjun1101 于 2007-4-28 14:43 发表
再次调的时候它选择的就只有LCC了mex -setup
Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers [y]/n? y

Select a com ...


这我就不懂了
 楼主| 发表于 2007-4-28 15:02 | 显示全部楼层
谢谢了
 楼主| 发表于 2007-4-28 23:38 | 显示全部楼层

matlab7.0创建接口文件时的问题

To get started, select MATLAB Help or Demos from the Help menu.
>> mex afdtdpbg.c
Specified export _mexFunction is not defined
Missing exports. Aborting

  D:\MATLAB7.0\BIN\WIN32\MEX.PL: Error: Link of 'afdtdpbg.dll' failed.

??? Error using ==> mex
Unable to complete successfully
>>

这个是运行时的代码,MEX.PL就是一个记事本,是不是在编写上有什么问题呢,MET-SETUP和SBUILD-SETUP已经建立好了,两个C++的程序已经贴到WORK目录下了,下面是MEX.PL的程序,大家帮忙想想是怎么了
  1. #
  2. #  Name:
  3. #     mex/mbuild Perl script for PC only.
  4. #
  5. #     mex  compilation program for MATLAB C/C++ and Fortran
  6. #                language MEX-files
  7. #
  8. #     mbuild  compilation program for executable programs for
  9. #                the MATLAB compiler.
  10. #
  11. #  Usage:
  12. #     MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
  13. #     [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
  14. #
  15. #     MBUILD [option1 ... optionN] sourcefile1 [... sourcefileN]
  16. #     [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
  17. #     [exportfile1 ... exportfileN]
  18. #
  19. #  Description:
  20. #     This Perl program provides dual functionality for MEX and MBUILD.
  21. #     The input argument '-mb' targets the routine to do MBUILD.
  22. #     Otherwise, it does MEX.
  23. #     
  24. #  Options:
  25. #
  26. #     See the 'describe' subroutine below for the MEX options.
  27. #
  28. #     See the 'describe_mb' subroutine below for the MBUILD options.
  29. #
  30. #  Options (undocumented):
  31. #
  32. #     -setup:$compiler[:$optionfile_type]
  33. #
  34. #           $compiler must be taken from the option file name:
  35. #
  36. #       <compiler>[<optionfile_type>]opts.bat  (mex)
  37. #       <compiler>compp.bat                    (mbuild)
  38. #
  39. #           Currently, <optionfile_type> = 'engmat' for mex only.
  40. #
  41. #     -f $destination
  42. #
  43. #           Where to put the options file. $destination must
  44. #     be $dir/$file where at least $dir exists and is
  45. #     writable. It can be used only with -setup. If
  46. #     not used the file is put in the default location:
  47. #
  48. #     PC:
  49. #           --
  50. #
  51. #        <UserProfile>\Application Data\MathWorks\MATLAB\R<version>
  52. #
  53. #           where
  54. #
  55. #       <UserProfile>    Is the value determined by Perl
  56. #          subroutine:
  57. #
  58. #          get_user_profile_dir
  59. #
  60. #    file: $MATLAB\bin\win32\getprofiledir.pm
  61. #      
  62. #       <version>        MATLAB Release number like 14.
  63. #
  64. #     UNIX/Linux/Mac:
  65. #           --------------
  66. #
  67. #  $HOME/.matlab/R<version>
  68. #
  69. #           where
  70. #
  71. #       <version>        MATLAB Release number like 14.
  72. #
  73. #  Option files:
  74. #
  75. #     mex:    $MATLAB\bin\win32\mexopts\*.stp
  76. #       $MATLAB\bin\win32\mexopts\*.bat
  77. #
  78. #             *opts.bat        files are 'installed' by -setup.
  79. #       *engmatopts.bat  files are arguments using -f only.
  80. #
  81. #     mbuild: $MATLAB\win\win32\mbuildopts\*.stp
  82. #             $MATLAB\win\win32\mbuildopts\*.bat
  83. #
  84. #
  85. #  Call structure:
  86. #
  87. #     mex.pl
  88. #        -> mexsetup.pm
  89. #           -> getprofiledir.pm
  90. #           MEX:
  91. #              -> mexopts/<compiler>opts.stp
  92. #           (compiler == msvc50 || msvc60)
  93. #       -> msvc_modules_installer.pm
  94. #        -> mexopts/<compiler>opts.bat
  95. #                 (compiler == bcc53 || bcc54 || bcc55 || bcc55free
  96. #          bcc56)
  97. #              -> link_borland_mex.pl
  98. #              -> mexopts/<compiler>engmatopts.bat
  99. #
  100. #           MBUILD:
  101. #        -> mbuildopts/<compiler>compp.stp
  102. #           (compiler == msvc50 || msvc60)
  103. #       -> msvc_modules_installer.pm
  104. #              -> mbuildopts/<compiler>compp.bat
  105. #                 (compiler == bcc54 || bcc55 || bcc55free || bcc56)
  106. #              -> link_borland_mex.pl
  107. #
  108. #  Globals:
  109. #
  110. #     $main::mbuild           => {"yes", "no"}
  111. #                                mbuild or mex?
  112. #     $main::script_directory => string with $MATLAB\bin in it.
  113. #     $main::cmd_name         => {"MBUILD.BAT", "MEX.BAT"}
  114. #     $main::no_execute       => {0, 1}
  115. #                                RunCmd execute command?
  116. #                                (used by -n switch)
  117. #  Internals:
  118. #
  119. #     @setup_args = ($compiler,$optionsfile_type,$destination)
  120. #
  121. #                    $compiler,$optionsfile_type values come from the
  122. #                        '-setup' argument.      
  123. #                    $destination value comes from the '-f' argument.
  124. #
  125. # Copyright 1984-2004 The MathWorks, Inc.
  126. # $Revision: 1.161.4.12 $
  127. #__________________________________________________________________________
  128. #
  129. #=======================================================================
  130. sub tool_name
  131. {
  132.     #===================================================================
  133.     # tool_name: Returns the tool name, i.e. mex or mbuild.
  134.     #===================================================================
  135.    
  136.     if ($main::mbuild eq "yes")
  137.     {
  138.         "mbuild";
  139.     }
  140.     else
  141.     {
  142.         "mex";
  143.     }
  144. }
  145. #=======================================================================
  146. BEGIN
  147. {
  148.     #===================================================================
  149.     # Set @INC for 5.00503 perl.
  150.     # If perl gets upgraded, this may have to be changed.
  151.     #===================================================================
  152.     if ( $] < 5.00503 ) {
  153. die "ERROR: This script requires perl 5.00503 or higher.
  154. You have perl $] installed on your machine and you did not set MATLAB variable,
  155. so the correct version of perl could not be found";
  156.     }
  157.     $main::mbuild = scalar(grep {/^-mb$/i} @ARGV) ? 'yes' : 'no';
  158.     my($f) = $0;
  159.     $f =~ s%[\\/][\w\.]+[\\/]\.\.[\\/]%\\%g;
  160.     $f =~ s%^[^\.][^\\/]+[\\/]\.\.[\\/]%%g;
  161.     # print "$0 -> $f ";
  162.     $0 = $f;
  163.     if ($f =~ s%^bin[\\/]win32[\\/].*%% ) {
  164. $f = '.';
  165.     } elsif ($f =~ s%[\\/]bin[\\/]win32[\\/].*%% ) {
  166. # fine
  167.     } else {
  168. $f .= "[url=file://\\..\\..\\]\\..\\..\\[/url]..";
  169. $f =~ s%\\[^\.][^\\]+\\\.\.\\%\\%g;
  170. $f =~ s%^[^\.][^\\]+\\\.\.\\%%g;
  171.     }
  172.     # print "-> $f\n";
  173.    
  174.     if ( ! $ENV{"MATLAB"} ) {
  175. $ENV{'MATLAB'} = $f;
  176.     } else {
  177. if ( $ENV{"MATLAB"} ne $f ) {
  178.             warn "\nWARNING: Your MATLAB environment variable is set to \n";
  179.             warn "    $ENV{'MATLAB'}\n";
  180.             warn "This does not match with the MATLAB path, \n";
  181.             warn "    $f\n";
  182.             warn "from where the " . uc(&tool_name()) . " script is being run.\n";
  183.             warn "Your MATLAB path for " . uc(&tool_name()) . " is assumed to be \n";
  184.             warn "    $ENV{'MATLAB'}\n";
  185.             warn "If this is not the correct path, please modify the\n";
  186.             warn "MATLAB environment variable before running the " . uc(&tool_name()) . "\n";
  187.             warn "script (or before starting MATLAB if you are running the\n";
  188.             warn uc(&tool_name()) . " script from within MATLAB.)\n\n";
  189.      }
  190.     }
  191.     if ( $ENV{'MATLAB'} ) {
  192. unshift (@INC, map { "$ENV{MATLAB}/sys/perl/win32/$_" }
  193.    ("lib", "site/lib"));
  194.         push(@INC, "$ENV{MATLAB}/bin/win32");
  195.     } else {
  196. warn "WARNING: MATLAB variable is not set.";
  197.     }
  198. }
  199. #=======================================================================
  200. use Cwd;
  201. use mexsetup;
  202. use getprofiledir;
  203. use File::DosGlob 'glob';
  204. use File::Basename;
  205. require "shellwords.pl";  # Found in $MATLAB/sys/perl/win32/lib
  206.                           # This is necessary to break up the text in
  207.      # the file into shell arguments. This is used
  208.      # to support the @<rspfile> argument.
  209. ########################################################################
  210. #=======================================================================
  211. # Common subroutines:
  212. #=======================================================================
  213. #
  214. # compile_files:      Compile files and form list of files to
  215. #                            link.
  216. # compile_resource:      Compile the resource.
  217. # do_setup:       Do only the setup.
  218. # emit_compile_step:      Output compile step to makefile.
  219. # emit_delete_resource_file: Output delete resource file to makefile.
  220. # emit_link_dependency:      Output link dependency to makefile.
  221. # emit_linker_step:          Output linker step to makefile.
  222. # emit_makedef:       Output makedef step to makefile.
  223. # emit_makefile_terminator:  Output terminator for makefile.
  224. # emit_postlink_step:      Output postlink step to makefile.
  225. # emit_prelink:       Output prelink step to makefile.
  226. # emit_resource_compiler:    Output resource compile step to makefile.
  227. # emit_resource_linker_step: Output resource linker step to makefile.
  228. # expand_wildcards:          Expand possible wildcards in the arguments
  229. #                            for perl >= 5.00503
  230. # expire:                    Die but with cleanup.
  231. # find_options_file:       Find the options file.
  232. # fix_common_variables:      Fix common variables.
  233. # fix_flag_variables:      Fix the flag variables.
  234. # files_to_remove:      Add files to remove list.
  235. # init_common:       Common initialization.
  236. # linker_arguments:          Create response file of linker arguments or
  237. #                            just string.  
  238. # link_files:       Link files.
  239. # options_file:              Get options file if not passed as an
  240. #                            argument. Source the options file.
  241. # parse_common_dash_args:    Parse the common dash arguments.
  242. # parse_common_nodash_args:  Parse the common non-dash arguments.
  243. # postlink:       Do postlink steps.
  244. # prelink:       Do prelink steps.
  245. # process_overrides:         Process command line overrides.
  246. # process_response_file:     Run shellwords on filename argument.
  247. # rectify_path:              Check path for system directories and add
  248. #                            them if not present.
  249. # resource_linker:      Run resource linker.
  250. # RunCmd:        Run a single command.
  251. # search_path:       Search DOS PATH environment for $binary_name
  252. #                            argument
  253. # set_common_variables:      Set more common variables.
  254. # smart_quote:       Add quotes around strings with space.
  255. # start_makefile:      Open and write the main dependency to the
  256. #                            makefile.
  257. # tool_name:       Returns the tool name, i.e. mex or mbuild. This
  258. #                        function is defined at the top of the script since
  259. #                        it is used in the BEGIN block.
  260. #
  261. #-----------------------------------------------------------------------
  262. #
  263. # Common variables:
  264. #
  265. #   perl:
  266. #
  267. #     FILES_TO_REMOVE
  268. #     FILES_TO_LINK
  269. #     FLAGS
  270. #     LINKFLAGS
  271. #     MAKEFILE
  272. #
  273. #   DOS environment:
  274. #
  275. #     PATH                      system path
  276. #     MATLAB   MATLAB root
  277. #
  278. #     [$ENV: get in script]
  279. #       MEX_DEBUG  This is for debugging this script.
  280. #
  281. #     [$ENV: set in script]
  282. #       LIB_NAME
  283. #       MATLAB   MATLAB root
  284. #       MATLAB_BIN
  285. #       MATLAB_EXTLIB
  286. #       OUTDIRN
  287. #       OUTDIR
  288. #       RES_NAME
  289. #       RES_PATH
  290. #  
  291. #=======================================================================
  292. sub compile_files
  293. {
  294.     #===================================================================
  295.     # compile_files: Compile files and form list of files to link.
  296.     #===================================================================
  297.     # Loop over @FILES to compile each file.  Keep files we actually
  298.     # compile separate from the ones we don't compile but need to link.
  299.     # This way, we can later clean up all .obj files we created.
  300.     #
  301.     for (;$_=shift(@FILES);) {
  302.         ($FILENAME, $EXTENSION) = (/([ \w]+)\.(\w*)$/);
  303.         if ($EXTENSION =~ /($COMPILE_EXTENSION)$/i ) {
  304.      my ($target_name, $name_arg);
  305.             if ($NAME_OBJECT) {
  306.                 $target_name = "$ENV{'OUTDIR'}$FILENAME.obj";
  307.                 $name_arg = $NAME_OBJECT . &smart_quote($target_name);
  308.             }
  309.             else {
  310.                 $target_name = "$FILENAME.obj";
  311.                 $name_arg = "";
  312.             }
  313.      my ($args) =
  314.          "$ARG_FLAGS $COMPFLAGS $name_arg $FLAGS " . &smart_quote($_);
  315.             if (!$makefilename)
  316.             {
  317.                 my $messages = RunCmd("$COMPILER $args");

  318.                 # Check for error; $? might not work, so also check for resulting file
  319.                 #
  320.                 if ($? != 0 || !(-e "$target_name" || $main::no_execute)) {
  321.                     print "$messages" unless $verbose; # verbose => printed in RunCmd
  322.                     &expire("Error: Compile of '$_' failed.");
  323.                 }
  324.                 if (!$compile_only)
  325.                 {
  326.                     push(@FILES_TO_REMOVE, "$target_name");
  327.                 }
  328.             }
  329.             else
  330.             {
  331.   &emit_compile_step();
  332.             }
  333.             push(@FILES_TO_LINK, "$LINK_FILE " . &smart_quote($target_name));
  334.             push(@FILES_TO_LINK_BASE, &smart_quote($target_name));
  335.         }
  336.         elsif ($EXTENSION =~ /lib$/i)
  337.         {
  338.             push(@FILES_TO_LINK, "$LINK_LIB " . &smart_quote($_));
  339.             push(@FILES_TO_LINK_BASE, &smart_quote($_));
  340.         }
  341.         else
  342.         {
  343.             push(@FILES_TO_LINK, "$LINK_FILE " . &smart_quote($_));
  344.             push(@FILES_TO_LINK_BASE, &smart_quote($_));
  345.         }
  346.     }
  347. }
  348. #=======================================================================
  349. sub compile_resource
  350. {
  351.     #===================================================================
  352.     # compile_resource: Compile the resource.
  353.     #===================================================================
  354.     my ($rc_line) = '';
  355.     $rc_line .= " -DARRAY_ACCESS_INLINING" if ($inline);
  356.     $rc_line .= " -DV5_COMPAT" if ($v5);
  357.     $rc_line .= " " . &smart_quote("$ENV{'RES_PATH'}$ENV{'RES_NAME'}.rc");
  358.     if (!$makefilename)
  359.     {
  360.         my $messages = RunCmd("$RC_COMPILER $rc_line");
  361.         # Check for error; $? might not work, so also check for string "error"
  362.         #
  363.         if ($? != 0 || $messages =~ /\b(error|fatal)\b/i) {
  364.             print "$messages" unless $verbose; # verbose => printed out in RunCmd
  365.             &expire("Error: Resource compile of '$ENV{'RES_NAME'}.rc' failed.");
  366.         }
  367.         push(@FILES_TO_REMOVE, "$ENV{'OUTDIR'}$ENV{'RES_NAME'}.res");
  368.     }
  369.     else
  370.     {
  371.         &emit_resource_compiler();
  372.     }
  373.    
  374.     push(@FILES_TO_LINK, &smart_quote("$ENV{'OUTDIR'}$ENV{'RES_NAME'}.res"));
  375. }
复制代码

后续
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-5 11:51 , Processed in 0.082769 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表