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
晕啊,最后一个问题了,这是嘛意思啊 :loveliness:

eight 发表于 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
晕啊,最后 ...

按照第二行英文的文件模版,修改第一行英文的文件

dongjun1101 发表于 2007-4-28 14:17

我要是认识你就好了,疯了我了,是把那个文件贴到目标文件里,覆盖原来的吗

dongjun1101 发表于 2007-4-28 14:19

:funk: D:\MATLAB7.0\BIN\WIN32\mexopts\lccopts.bat 我没有这个文件呢

eight 发表于 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吧

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\BIN\WIN32\mexopts\lccopts.bat
第一次的确是msvc60opts.bat
这是为什么呢

eight 发表于 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吧

dongjun1101 发表于 2007-4-28 14:31

那你看看我一开始给你发的最长的那写程序,我选的都是VC啊,怎么会LCC呢,我哪步弄错了呢

eight 发表于 2007-4-28 14:34

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

最长的那个是没错的,建议重新setup一次,选择VC的

dongjun1101 发表于 2007-4-28 14:37

这个mbuild 和 mex 是只能做一次吗,再做就不对了

[ 本帖最后由 eight 于 2007-4-28 14:38 编辑 ]

eight 发表于 2007-4-28 14:38

原帖由 dongjun1101 于 2007-4-28 14:37 发表
这个mbuild 和 mex 是只能做一次吗,再做就不对了
不可能吧,再调用 mbuild -setup 和 mex -setup 不行吗?

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 /n? y

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

None

Compiler: 1

Please verify your choices:

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

Are these correct?(/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 /n? y

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

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 /n? mbuild -setup

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

None

Compiler: mbuild -setup
Please select from 0-1
Compiler:
这是一部分

eight 发表于 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 /n? y

Select a com ...

这我就不懂了

dongjun1101 发表于 2007-4-28 15:02

谢谢了

dongjun1101 发表于 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的程序,大家帮忙想想是怎么了
#
#Name:
#   mex/mbuild Perl script for PC only.
#
#   mexcompilation program for MATLAB C/C++ and Fortran
#                language MEX-files
#
#   mbuildcompilation program for executable programs for
#                the MATLAB compiler.
#
#Usage:
#   MEX sourcefile1 [... sourcefileN]
#   
#
#   MBUILD sourcefile1 [... sourcefileN]
#   
#   
#
#Description:
#   This Perl program provides dual functionality for MEX and MBUILD.
#   The input argument '-mb' targets the routine to do MBUILD.
#   Otherwise, it does MEX.
#   
#Options:
#
#   See the 'describe' subroutine below for the MEX options.
#
#   See the 'describe_mb' subroutine below for the MBUILD options.
#
#Options (undocumented):
#
#   -setup:$compiler[:$optionfile_type]
#
#         $compiler must be taken from the option file name:
#
#       <compiler>[<optionfile_type>]opts.bat(mex)
#       <compiler>compp.bat                  (mbuild)
#
#         Currently, <optionfile_type> = 'engmat' for mex only.
#
#   -f $destination
#
#         Where to put the options file. $destination must
#   be $dir/$file where at least $dir exists and is
#   writable. It can be used only with -setup. If
#   not used the file is put in the default location:
#
#   PC:
#         --
#
#      <UserProfile>\Application Data\MathWorks\MATLAB\R<version>
#
#         where
#
#       <UserProfile>    Is the value determined by Perl
#          subroutine:
#
#          get_user_profile_dir
#
#    file: $MATLAB\bin\win32\getprofiledir.pm
#      
#       <version>      MATLAB Release number like 14.
#
#   UNIX/Linux/Mac:
#         --------------
#
#$HOME/.matlab/R<version>
#
#         where
#
#       <version>      MATLAB Release number like 14.
#
#Option files:
#
#   mex:    $MATLAB\bin\win32\mexopts\*.stp
#       $MATLAB\bin\win32\mexopts\*.bat
#
#             *opts.bat      files are 'installed' by -setup.
#       *engmatopts.batfiles are arguments using -f only.
#
#   mbuild: $MATLAB\win\win32\mbuildopts\*.stp
#             $MATLAB\win\win32\mbuildopts\*.bat
#
#
#Call structure:
#
#   mex.pl
#      -> mexsetup.pm
#         -> getprofiledir.pm
#         MEX:
#            -> mexopts/<compiler>opts.stp
#         (compiler == msvc50 || msvc60)
#       -> msvc_modules_installer.pm
#      -> mexopts/<compiler>opts.bat
#               (compiler == bcc53 || bcc54 || bcc55 || bcc55free
#          bcc56)
#            -> link_borland_mex.pl
#            -> mexopts/<compiler>engmatopts.bat
#
#         MBUILD:
#      -> mbuildopts/<compiler>compp.stp
#         (compiler == msvc50 || msvc60)
#       -> msvc_modules_installer.pm
#            -> mbuildopts/<compiler>compp.bat
#               (compiler == bcc54 || bcc55 || bcc55free || bcc56)
#            -> link_borland_mex.pl
#
#Globals:
#
#   $main::mbuild         => {"yes", "no"}
#                              mbuild or mex?
#   $main::script_directory => string with $MATLAB\bin in it.
#   $main::cmd_name         => {"MBUILD.BAT", "MEX.BAT"}
#   $main::no_execute       => {0, 1}
#                              RunCmd execute command?
#                              (used by -n switch)
#Internals:
#
#   @setup_args = ($compiler,$optionsfile_type,$destination)
#
#                  $compiler,$optionsfile_type values come from the
#                        '-setup' argument.      
#                  $destination value comes from the '-f' argument.
#
# Copyright 1984-2004 The MathWorks, Inc.
# $Revision: 1.161.4.12 $
#__________________________________________________________________________
#
#=======================================================================
sub tool_name
{
    #===================================================================
    # tool_name: Returns the tool name, i.e. mex or mbuild.
    #===================================================================
   
    if ($main::mbuild eq "yes")
    {
      "mbuild";
    }
    else
    {
      "mex";
    }
}
#=======================================================================
BEGIN
{
    #===================================================================
    # Set @INC for 5.00503 perl.
    # If perl gets upgraded, this may have to be changed.
    #===================================================================
    if ( $] < 5.00503 ) {
die "ERROR: This script requires perl 5.00503 or higher.
You have perl $] installed on your machine and you did not set MATLAB variable,
so the correct version of perl could not be found";
    }
    $main::mbuild = scalar(grep {/^-mb$/i} @ARGV) ? 'yes' : 'no';
    my($f) = $0;
    $f =~ s%[\\/][\w\.]+[\\/]\.\.[\\/]%\\%g;
    $f =~ s%^[^\.][^\\/]+[\\/]\.\.[\\/]%%g;
    # print "$0 -> $f ";
    $0 = $f;
    if ($f =~ s%^bin[\\/]win32[\\/].*%% ) {
$f = '.';
    } elsif ($f =~ s%[\\/]bin[\\/]win32[\\/].*%% ) {
# fine
    } else {
$f .= "\\..\\..\\..";
$f =~ s%\\[^\.][^\\]+\\\.\.\\%\\%g;
$f =~ s%^[^\.][^\\]+\\\.\.\\%%g;
    }
    # print "-> $f\n";
   
    if ( ! $ENV{"MATLAB"} ) {
$ENV{'MATLAB'} = $f;
    } else {
if ( $ENV{"MATLAB"} ne $f ) {
            warn "\nWARNING: Your MATLAB environment variable is set to \n";
            warn "    $ENV{'MATLAB'}\n";
            warn "This does not match with the MATLAB path, \n";
            warn "    $f\n";
            warn "from where the " . uc(&tool_name()) . " script is being run.\n";
            warn "Your MATLAB path for " . uc(&tool_name()) . " is assumed to be \n";
            warn "    $ENV{'MATLAB'}\n";
            warn "If this is not the correct path, please modify the\n";
            warn "MATLAB environment variable before running the " . uc(&tool_name()) . "\n";
            warn "script (or before starting MATLAB if you are running the\n";
            warn uc(&tool_name()) . " script from within MATLAB.)\n\n";
   }
    }
    if ( $ENV{'MATLAB'} ) {
unshift (@INC, map { "$ENV{MATLAB}/sys/perl/win32/$_" }
   ("lib", "site/lib"));
      push(@INC, "$ENV{MATLAB}/bin/win32");
    } else {
warn "WARNING: MATLAB variable is not set.";
    }
}
#=======================================================================
use Cwd;
use mexsetup;
use getprofiledir;
use File::DosGlob 'glob';
use File::Basename;
require "shellwords.pl";# Found in $MATLAB/sys/perl/win32/lib
                        # This is necessary to break up the text in
   # the file into shell arguments. This is used
   # to support the @<rspfile> argument.
########################################################################
#=======================================================================
# Common subroutines:
#=======================================================================
#
# compile_files:      Compile files and form list of files to
#                            link.
# compile_resource:      Compile the resource.
# do_setup:       Do only the setup.
# emit_compile_step:      Output compile step to makefile.
# emit_delete_resource_file: Output delete resource file to makefile.
# emit_link_dependency:      Output link dependency to makefile.
# emit_linker_step:          Output linker step to makefile.
# emit_makedef:       Output makedef step to makefile.
# emit_makefile_terminator:Output terminator for makefile.
# emit_postlink_step:      Output postlink step to makefile.
# emit_prelink:       Output prelink step to makefile.
# emit_resource_compiler:    Output resource compile step to makefile.
# emit_resource_linker_step: Output resource linker step to makefile.
# expand_wildcards:          Expand possible wildcards in the arguments
#                            for perl >= 5.00503
# expire:                  Die but with cleanup.
# find_options_file:       Find the options file.
# fix_common_variables:      Fix common variables.
# fix_flag_variables:      Fix the flag variables.
# files_to_remove:      Add files to remove list.
# init_common:       Common initialization.
# linker_arguments:          Create response file of linker arguments or
#                            just string.
# link_files:       Link files.
# options_file:            Get options file if not passed as an
#                            argument. Source the options file.
# parse_common_dash_args:    Parse the common dash arguments.
# parse_common_nodash_args:Parse the common non-dash arguments.
# postlink:       Do postlink steps.
# prelink:       Do prelink steps.
# process_overrides:         Process command line overrides.
# process_response_file:   Run shellwords on filename argument.
# rectify_path:            Check path for system directories and add
#                            them if not present.
# resource_linker:      Run resource linker.
# RunCmd:      Run a single command.
# search_path:       Search DOS PATH environment for $binary_name
#                            argument
# set_common_variables:      Set more common variables.
# smart_quote:       Add quotes around strings with space.
# start_makefile:      Open and write the main dependency to the
#                            makefile.
# tool_name:       Returns the tool name, i.e. mex or mbuild. This
#                        function is defined at the top of the script since
#                        it is used in the BEGIN block.
#
#-----------------------------------------------------------------------
#
# Common variables:
#
#   perl:
#
#   FILES_TO_REMOVE
#   FILES_TO_LINK
#   FLAGS
#   LINKFLAGS
#   MAKEFILE
#
#   DOS environment:
#
#   PATH                      system path
#   MATLAB   MATLAB root
#
#   [$ENV: get in script]
#       MEX_DEBUGThis is for debugging this script.
#
#   [$ENV: set in script]
#       LIB_NAME
#       MATLAB   MATLAB root
#       MATLAB_BIN
#       MATLAB_EXTLIB
#       OUTDIRN
#       OUTDIR
#       RES_NAME
#       RES_PATH
#
#=======================================================================
sub compile_files
{
    #===================================================================
    # compile_files: Compile files and form list of files to link.
    #===================================================================
    # Loop over @FILES to compile each file.Keep files we actually
    # compile separate from the ones we don't compile but need to link.
    # This way, we can later clean up all .obj files we created.
    #
    for (;$_=shift(@FILES);) {
      ($FILENAME, $EXTENSION) = (/([ \w]+)\.(\w*)$/);
      if ($EXTENSION =~ /($COMPILE_EXTENSION)$/i ) {
   my ($target_name, $name_arg);
            if ($NAME_OBJECT) {
                $target_name = "$ENV{'OUTDIR'}$FILENAME.obj";
                $name_arg = $NAME_OBJECT . &smart_quote($target_name);
            }
            else {
                $target_name = "$FILENAME.obj";
                $name_arg = "";
            }
   my ($args) =
         "$ARG_FLAGS $COMPFLAGS $name_arg $FLAGS " . &smart_quote($_);
            if (!$makefilename)
            {
                my $messages = RunCmd("$COMPILER $args");

                # Check for error; $? might not work, so also check for resulting file
                #
                if ($? != 0 || !(-e "$target_name" || $main::no_execute)) {
                  print "$messages" unless $verbose; # verbose => printed in RunCmd
                  &expire("Error: Compile of '$_' failed.");
                }
                if (!$compile_only)
                {
                  push(@FILES_TO_REMOVE, "$target_name");
                }
            }
            else
            {
&emit_compile_step();
            }
            push(@FILES_TO_LINK, "$LINK_FILE " . &smart_quote($target_name));
            push(@FILES_TO_LINK_BASE, &smart_quote($target_name));
      }
      elsif ($EXTENSION =~ /lib$/i)
      {
            push(@FILES_TO_LINK, "$LINK_LIB " . &smart_quote($_));
            push(@FILES_TO_LINK_BASE, &smart_quote($_));
      }
      else
      {
            push(@FILES_TO_LINK, "$LINK_FILE " . &smart_quote($_));
            push(@FILES_TO_LINK_BASE, &smart_quote($_));
      }
    }
}
#=======================================================================
sub compile_resource
{
    #===================================================================
    # compile_resource: Compile the resource.
    #===================================================================
    my ($rc_line) = '';
    $rc_line .= " -DARRAY_ACCESS_INLINING" if ($inline);
    $rc_line .= " -DV5_COMPAT" if ($v5);
    $rc_line .= " " . &smart_quote("$ENV{'RES_PATH'}$ENV{'RES_NAME'}.rc");
    if (!$makefilename)
    {
      my $messages = RunCmd("$RC_COMPILER $rc_line");
      # Check for error; $? might not work, so also check for string "error"
      #
      if ($? != 0 || $messages =~ /\b(error|fatal)\b/i) {
            print "$messages" unless $verbose; # verbose => printed out in RunCmd
            &expire("Error: Resource compile of '$ENV{'RES_NAME'}.rc' failed.");
      }
      push(@FILES_TO_REMOVE, "$ENV{'OUTDIR'}$ENV{'RES_NAME'}.res");
    }
    else
    {
      &emit_resource_compiler();
    }
   
    push(@FILES_TO_LINK, &smart_quote("$ENV{'OUTDIR'}$ENV{'RES_NAME'}.res"));
}

后续
页: 1 [2]
查看完整版本: matlab7.0和C++的接口问题