[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: External C DLL crashes Octave
From: |
Tatsuro MATSUOKA |
Subject: |
Re: External C DLL crashes Octave |
Date: |
Sat, 29 Aug 2009 04:17:08 +0900 (JST) |
Hello
Please show the version of octave and whether it is MSVC version or MinGW
Version.
Regards
Tatsuro
--- 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.
>
> ----------------------------dllmain.cpp------------------------------
> #include "stdafx.h"
>
> BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID
> lpReserved ) {
> switch (ul_reason_for_call)
> {
> case DLL_PROCESS_ATTACH:
> case DLL_THREAD_ATTACH:
> case DLL_THREAD_DETACH:
> case DLL_PROCESS_DETACH:
> break;
> }
> return TRUE;
> }
> ----------------------------mycode.cpp------------------------------
> #include <stdio.h>
> #include <stdlib.h>
>
> extern "C" unsigned int func1(double *x);
>
> unsigned int func1(double *x)
> {
> ...
> }
> ----------------------------mycodewrapper.cc------------------------------
> #include <octave/oct.h>
>
> extern "C" {
> unsigned int func1(double *x);
> }
> DEFUN_DLD (func1, args, , "usage func1('double')" ) {
> octave_value_list retval;
> Matrix B = args(0).matrix_value();
> double* A;
> *A = B.data(0);
> retval(0) = (double) func1( A );
> return retval;
> }
>
> --
> View this message in context:
> http://www.nabble.com/External-C-DLL-crashes-Octave-tp25189231p25189231.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
--------------------------------------
Thanks 10 years! Yahoo! Shopping and Yahoo! Auctions
http://pr.mail.yahoo.co.jp/ec10years/
Re: External C DLL crashes Octave, Benjamin Lindner, 2009/08/30