Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

MatLab and Code::Blocks

<< < (3/4) > >>

MortenMacFly:

--- Quote from: zergling on January 10, 2011, 08:48:25 am ---I was just wondering if you got the file  :o

--- End quote ---
Yes, I got it but didn't find the time to look into...

MortenMacFly:
OK, I see here:

--- Quote ---./R2010b/extern:
examples
include
lib

--- End quote ---
...the include folder should be [MATLAB]/extern/include, [MATLAB]/simulink/include, the library folder /extern/lib/glnxa64 and another one I am missing where all the link libraries are installed into. Most likely these have been put under /usr/local/lib/matlab or something like that... can you check that (it depends on the Linux platform unfortunately)? You can search for e.g. libmex* on your HDD and look if you find libmex.a somewhere.

Note that is seems you'll need [MATLAB]/bin/glnxa64 in the LD_LIBRARY path (if not already there).

What you can do alternatively anyways is setting up the compiler inside Matlab to be verbose and inspect what's printed on the command prompt There should be the whole command line including all flags / include folder you'll need. You'll find the option somewhere in the preferences. Not sure where on Linux.

zergling:
Hi,
I am still getting the message "The Matlab path you entered seems valid, but this wizard
can't locate the Matlab extern include path in the sub-directory /extern/include"
Is it possible (when you have time) to go over the code::blocks script wizard and all the settings together?
Or, would be possible to have the matlab script implemented within the next nightly build (like in the win version)?
I am really sorry for bugging you so much, but I do really love this compiler  8)

MortenMacFly:

--- Quote from: zergling on January 13, 2011, 04:25:28 am ---Hi,
I am still getting the message "The Matlab path you entered seems valid, but this wizard
can't locate the Matlab extern include path in the sub-directory /extern/include"
Is it possible (when you have time) to go over the code::blocks script wizard and all the settings together?
Or, would be possible to have the matlab script implemented within the next nightly build (like in the win version)?
I am really sorry for bugging you so much, but I do really love this compiler  8)

--- End quote ---
What I see from a quick look:
This line:

--- Code: ---if (!IO.DirectoryExists(dir_nomacro + _T("/media/school/MATLAB/R2010b/extern/include")))
--- End code ---
...cannot work and will always return false. Notice that you enter the patch to Matlab in the wizard - so in your case it's /media/school/MATLAB/R2010b. If you combine the path entered as you do you get the following directory:
/media/school/MATLAB/R2010b/media/school/MATLAB/R2010b/extern/include
...which does not exist - that's what the wizard complains.

Look: I can't do a wizard for Matlab under Linux as I don't have Matlab under Linux and I won't commit things that most likely will not work as they are untested. I'll need your help for the trials. BTW: Hard-coded path's should not be in the wizard anyways. The wizard asks for a base directory. All other directories in the wizard should either be relative or in combination with the base directory.

zergling:
Thank you for your help!
Finally I was able to go over the script wizard :D

The only problem it that I do not know which header files I have to include...
By default I have #include <windows.h> that is for a windows system.

This is what I have done so far with the matlab script wizard.
By the way, can I remove all the lcc references in the script?

--- Code: ---////////////////////////////////////////////////////////////////////////////////
//
// Matlab S-Function project wizard
//
////////////////////////////////////////////////////////////////////////////////

// globals
MatlabPath <- _T("");

function BeginWizard()
{
  local intro_msg = _T("Welcome to the new Matlab C-S-Function project wizard!\n\n" +
                       "This wizard will guide you to create a new project\n" +
                       "creating a Matlab C-S-Function using the GCC\n" +
                       "or Matlab LCC compiler.\n\n" +
                       "For GCC you must have converted the Matlab DLL's into\n" +
                       "GCC compatible libraries using the DLLTOOL before.\n" +
                       "This wizard expects the GCC libraries at the location:\n" +
                       "[MATLAB]/extern/lib/win32/gcc\n\n" +
                       "When you're ready to proceed, please click \"Next\"...");

  local matlabpath_descr = _T("Please select the location of Matlab on your computer.\n" +
                              "This is the top-level folder where Matlab was installed.");

  Wizard.AddInfoPage(_T("MatlabCSFIntro"), intro_msg); // intro
  Wizard.AddProjectPathPage();
  Wizard.AddCompilerPage(_T(""), _T("gcc;lcc"), true, false); // compiler selection but no path selection
  Wizard.AddGenericSelectPathPage(_T("MatlabPath"), matlabpath_descr, _T("Please select Matlab's location:"), _T("$(#matlab)"));
  Wizard.AddPage(_T("MatlabHint"));
}

////////////////////////////////////////////////////////////////////////////////
// Matlab's path page
////////////////////////////////////////////////////////////////////////////////

function OnLeave_MatlabPath(fwd)
{
  if (fwd)
  {
    local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
    local dir_nomacro = ReplaceMacros(dir, true);
    if (!IO.DirectoryExists(dir_nomacro))
    {
      ShowError(_T("Please select a valid path to Matlab..."));
      return false;
    }
    // Verify Matlab extern includes
    if (!IO.DirectoryExists(dir_nomacro + _T("/extern/include")))
    {
      ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
                   "can't locate the Matlab extern include path in the sub-directory /extern/include"));
      return false;
    }
    // Verify Matlab extern tmwtypes.h (Simulink types)
    if (!IO.FileExists(dir_nomacro + _T("/extern/include/tmwtypes.h")))
    {
      ShowError(_T("The Matlab extern path seems valid, but this wizard\n" +
                   "can't locate the Matlab twmtypes.h in it."));
      return false;
    }
    // Verify Simulink includes
    if (!IO.DirectoryExists(dir_nomacro + _T("/simulink/include")))
    {
      ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
                   "can't locate the Simulink include path in the sub-directory\n"
                   "/simulink/include"));
      return false;
    }
    // Verify Matlab extern tmwtypes.h (Simulink types)
    if (!IO.FileExists(dir_nomacro + _T("/simulink/include/simstruc.h")))
    {
      ShowError(_T("The Matlab-Simulink include path seems valid, but this wizard\n" +
                   "can't locate the Matlab simstruc.h in it."));
      return false;
    }

    MatlabPath = dir;
  }
  return true;
}

// return the files this project contains
function GetFilesDir()
{
  local result = _T("matlab_csf/files");
  if (Wizard.GetCompilerID().Matches(_T("lcc")))
    result += _T(";matlab_csf/lccstub");

  return result;
}

// setup the already created project
function SetupProject(project)
{

  if (Wizard.GetCompilerID().Matches(_T("gcc")))
  {
    // set project options for GCC
    project.SetModeForPCH(pchSourceDir);
    project.AddCompilerOption(_T("-malign-double"));    // 8 byte alignment
    project.AddCompilerOption(_T("-fno-exceptions"));   // exception free code

    project.AddLinkerOption(_T("-shared"));
    project.AddLinkerOption(_T("-Wl,--out-implib=sfuntmpl")+DOT_EXT_STATICLIB);
    project.AddLibDir(MatlabPath + _T("/extern/lib/win32/gcc"));
  }
  else
  {
    ShowError(_T("The selected compiler is not compatible with Matlab.\n" +
                 "The wizard cannot continue."));
    return false;
  }

  // set common project options (the same for both compilers)
  project.AddCompilerOption(_T("-DNDEBUG"));
  project.AddCompilerOption(_T("-DMATLAB_MEX_FILE"));

  project.AddIncludeDir(MatlabPath + _T("\\extern\\include"));
  project.AddIncludeDir(MatlabPath + _T("\\simulink\\include"));

  project.AddLinkLib(_T("libmx"));
  project.AddLinkLib(_T("libmex"));
  project.AddLinkLib(_T("libmatlb"));
  project.AddLinkLib(_T("libmat"));

  // Debug
  local target = project.GetBuildTarget(Wizard.GetDebugName());
  if (!IsNull(target))
  {
    target.SetTargetType(ttDynamicLib);
    // the s-function DLL must have the same name as the file/function
    target.SetOutputFilename(_T("sfuntmpl") + DOT_EXT_DYNAMICLIB);
    target.SetWorkingDir(_T("."));

    if (Wizard.GetCompilerID().Matches(_T("lcc")))
    {
      // It only works that way because the LCC resource compiler does not
      // support creating it's "object files" (*.res) in any sub-directory
      target.SetObjectOutput(_T(".")); //
    }
  }

  // Release
  target = project.GetBuildTarget(Wizard.GetReleaseName());
  if (!IsNull(target))
  {
    target.SetTargetType(ttDynamicLib);
    // the s-function DLL must have the same name as the file/function
    target.SetOutputFilename(_T("sfuntmpl") + DOT_EXT_DYNAMICLIB);
    target.SetWorkingDir(_T("."));

    if (Wizard.GetCompilerID().Matches(_T("lcc")))
    {
      // It only works that way because the LCC resource compiler does not
      // support creating it's "object files" (*.res) in any sub-directory
      target.SetObjectOutput(_T(".")); //
    }
  }

  return true;
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version