help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: External C DLL crashes Octave


From: Benjamin Lindner
Subject: Re: External C DLL crashes Octave
Date: Sun, 30 Aug 2009 14:00:26 +0200
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

mishrapiyush wrote:
Hi all,

  I followed the example on wiki
(http://wiki.octave.org/wiki.pl?OctaveLinkToWindowsDLLs) to compile my c/c++
code into an .oct file but when I try to call this function, octave crashes.
A snippet of my codes is attached below for your reference.

I had compiled mycode.cpp as Win DLL using MS Visual Studio 2008 and tested
it on Matlab. Next I had copied the mycode.dll and mycode.lib into my Octave
project folder and compiled them with mycodewrapper.cc to generate
func1.oct, which I call in a matlab function.

I have recetly started using Octave and have spent hours researching the
process of integrating external function calls. In my opinion, the manual
(Appendix A.1.9) does not do a good job of explaining C/C++ integration and
should be supplemented with wiki entry mentioned above, which itself misses
to mention that when linking the wrapper with external code, it should be
done with .lib file and not the .dll file. I would very much appreciate any
help in further resolving this problem. Thanks for your time.

Well, the fact that you cannot link against a .dll file is fairly obvious, in the sense that it is the way how it is done. If you want to link to a shared library you will need the appropriate import library along with corresponding header files.

But if you have the source code available, I'd recommend to compile it from source rather than to use a compiled .dll.
It works either way, but it might give you less problems.
Move the common core alorithm into a separate source code file and write separate wrappers for octave and matlab.

You might have spared you some of the hours of researching of you took a look at many examples on dynamically loaded functions in the examples/ subdirectory of the octave source code, or the source code of the .oct functions which are distributed along with octave.

benjamin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]