XOJO and MATLAB

Hello,
we use matlab code compiled under C/C++ to create a COM Object which is called by VB6 program.
Component Object Model is Microsoft product embedded in windows dll.
I know that Xojo use plugins written in C/C++, is there an other way similar of COM object ?

Xojo can work with COM objects. Search Help for COM.

Dean,
Help for ActiveX, COM and OLE seams poor, any tuto. or web site for more information ?

Hello,

I am just writing to show my interest on this topic too. I use Matlab at work and it would be nice to have the possibility of connecting it to Xojo.

Some time ago I tried to generate dlls in Matlab and used them via Declares in Xojo, but I never managed to get anywhere. I have to admit that I get lost with all these OLE/COM/ActiveX “things” (well, objects, I just wanted to show how little I know about this), plus I have no idea about creating dlls that can be used from xojo (it is my understanding that there are different type of dlls, right?).

I am willing to try things to connect the two in one way or another if I can help, but I lack the knowledge to decide what to try.

Julen

Hello Djamel,

Here are the condensed instructions to use a COM object in Xojo, and lets presume that the COM library is called XojoCom.atl for this example:

  1. copy the COM object into a directory (usually c:\windows\), and the file will be located at c:\windows\XojoCom.atl
  2. Register the COM object by typing in the command prompt “regsvr32 c:\windows\XojoCom.atl”
  3. Start Xojo and click the menu button 'Insert->ActiveX Component…" and click the References tab
  4. Click the component name with the correct path, it may be Xojo COM Type Library, version 1.0, path c:\windows\XojoCom.atl
  5. Press the OK button
  6. Wait about 30 seconds to 1 minute. If it is a large COM, then it will take more time.
  7. A module called XojoCom will appear in the Contents section of the Xojo IDE.
  8. Use dot notation to use the classes, enumerations, and structures that you would normally use like a Xojo module, except that you are using a MATLAB COM

:slight_smile:

[quote=354478:@Julen Ibarretxe Uriguen]Hello,

I am just writing to show my interest on this topic too. I use Matlab at work and it would be nice to have the possibility of connecting it to Xojo.

Some time ago I tried to generate dlls in Matlab and used them via Declares in Xojo, but I never managed to get anywhere. I have to admit that I get lost with all these OLE/COM/ActiveX “things” (well, objects, I just wanted to show how little I know about this), plus I have no idea about creating dlls that can be used from xojo (it is my understanding that there are different type of dlls, right?).

I am willing to try things to connect the two in one way or another if I can help, but I lack the knowledge to decide what to try.

Julen[/quote]
Under VB6 a COM object is very useful to use scientific algorithm which is more easy to build under matlab and compiled under C/C++ (Compiler connect to matlab) to be more faster then other high level languages.
Infortunately, my COM coded for VB6 annot be used under XOJO (I migrate from VB6 to XOJO).

[quote=354481:@Eugene Dakin]Hello Djamel,

Here are the condensed instructions to use a COM object in Xojo, and lets presume that the COM library is called XojoCom.atl for this example:

  1. copy the COM object into a directory (usually c:\windows\), and the file will be located at c:\windows\XojoCom.atl
  2. Register the COM object by typing in the command prompt “regsvr32 c:\windows\XojoCom.atl”
  3. Start Xojo and click the menu button 'Insert->ActiveX Component…" and click the References tab
  4. Click the component name with the correct path, it may be Xojo COM Type Library, version 1.0, path c:\windows\XojoCom.atl
  5. Press the OK button
  6. Wait about 30 seconds to 1 minute. If it is a large COM, then it will take more time.
  7. A module called XojoCom will appear in the Contents section of the Xojo IDE.
  8. Use dot notation to use the classes, enumerations, and structures that you would normally use like a Xojo module, except that you are using a MATLAB COM

:)[/quote]
I will try, anyway i am very glad that is possible to use a COM objects under XOJO.

I was asked to write a book on how to create a COM object, and then use it in Xojo. There is too much information to write and too little time to write it :slight_smile:

Eugene,
Any doc. about this subject it’s welcome !

Hello Eugene,
Since this time i have tried to do it without success.
Any link or any real example for this subject ?

Djamel, would you mind explaining to me how you compile the COM object?

I would like to compile a very simple project to try to use it in Xojo, just to get it working.

Thanks,

Julen

Sorry, I do not have an example at the moment.

Djamel, are you getting any error? In which step? Are your COM object and Xojo project both 32 or 64 bit? Have you installed the Matlab runtime on the machine you are using to test the COM object?

Yesterday I managed to create a COM object in Matlab, and also compiled my project as C dll, C++ dll and NET assembly dll.

I tried to use them in Xojo but I didn’t succeed, I will explore further later today. I think my problem was the dlls are 64bit and my xojo project is 32 bit (I don’t have a license for the current Xojo version, can I run my project from the IDE in 64 bits without a license?).

Julen

[quote=477102:@Julen Ibarretxe Uriguen]Djamel, would you mind explaining to me how you compile the COM object?

I would like to compile a very simple project to try to use it in Xojo, just to get it working.

Thanks,

Julen[/quote]
link text
Hello Julen,
in this link you can download the doc. about a COM Builder, since win 7 my Borland 4.5 compiler doesn’t run , so i can’t create COM in my matlab 2008.

[quote=477158:@Djamel AIT AMRANE]link text
Hello Julen,
in this link you can download the doc. about a COM Builder, since win 7 my Borland 4.5 compiler doesn’t run , so i can’t create COM in my matlab 2008.[/quote]

[quote=477158:@Djamel AIT AMRANE]@Julen Ibarretxe Uriguen Djamel, would you mind explaining to me how you compile the COM object?

I would like to compile a very simple project to try to use it in Xojo, just to get it working.

Thanks,

You can also use the link in your navigator : https://www.grosfichiers.com/iJDtCDy4dxb

I believe you can download and run the latest version of Xojo without a license. There are some restrictions like not being able to build a distributed version of your app or the project save formats, but you can certainly run a project in Debug mode in the IDE (and thus 64bit).

I hope that helps.

Thanks Scott. I misread the error message I got, it had nothing to do with 32 bits, it said it was not a valid win32 application, but win32 doesn’t mean 32 bits.

So, I compiled a very simple Matlab project into several dlls (C, C++ and NET assembly type, as per Matlab’s deploytool) and one COM object.

I managed to make Xojo recognize the COM object (as described by Eugene above) and the NET assembly dll (using a declare):

Declare Function MultiplyB2 Lib "d:\\libs\\MyMultiplyNative.dll" (number as double) as Double var Result as Double Result=MultiplyB2(2) MessageBox (Result.ToString)

In both cases I got errors which, if I am not wrong, mean the dll and COM object I created are not ok.

In the case of the NET assembly dll the error says "Failure Condition: functionEntry. Could not resolve funcion ‘MultiplyByTwo’ in d:\libs\MyMultiplyNative.dll

If I use the COM object the errors are:

EDIT: The image is here,

On the picture you can see three modules in my project. One of them correponds to the function I created in Matlab, and the other two were generated by Matlab and registered during the registration of my own COM object (Matlab generates an installer for the COM object, those two additional COM objects, and the Matlab Runtine). Initially I only had the module corresponding to my own function and Xojo complained about missing classes. Then I added the reference to the other two modules.

I lack the knowledge to try to solve this. At work I have access to the latest Matlab version, and we have licenses for all packages so I can try any suggestion you may come up with, but that’s about it.

Julen

Image error for Julen

This may help:
https://blog.xojo.com/2014/01/03/accessing-net-code-from-xojo/

I used it years ago to use DLLs created in VS.