|
楼主 |
发表于 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.
- #
- # mex compilation program for MATLAB C/C++ and Fortran
- # language MEX-files
- #
- # mbuild compilation program for executable programs for
- # the MATLAB compiler.
- #
- # Usage:
- # MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
- # [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
- #
- # MBUILD [option1 ... optionN] sourcefile1 [... sourcefileN]
- # [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
- # [exportfile1 ... exportfileN]
- #
- # 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.bat files 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 .= "[url=file://\\..\\..\\]\\..\\..\\[/url]..";
- $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_DEBUG This 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"));
- }
复制代码
后续 |
|