EDN Admin
Well-known member
I have been trying to use libraries from the scripting language Octave inside a Visual C++ program. I posted to their mailing lists, but received no response. So, heres the issue. I can compile my program successfully, but running the program results in the error message:
"The application failed to initialize properly (0x80000003). Click on OK to terminate the application."
I understand it is unlikely to find anyone who knows much about Octave so I will try to fill you in as much as possible. This is where you can go to download the software if you are interested in it:
http://octave.sourceforge.net/
As stated, Im trying to compile code while using the library created by code used by Octave. In this case, Im trying to use what is called a .mex file. .Mex files are c++ code which can be called by Octave and also have the capability to call other Octave functions. They are compiled with a command mkoctfile --mex, which in turn calls the associated compiler. Instructions for setting up the compiler were found here: http://www.geocities.jp/tmoctwin/msvcoct.html
Anyway, I created a sample program to try to link to. It follows her (addLib.cpp):<span class=ul-threaded style="margin:1em 0pt 0pt -20px <span class=connect><span id=li1 class=li-threaded><span class=threaded><span style="position:static;border-left-width:3px" class="no-bg-color post-border post-middle <span id=post18878959 style="display:block <span class=ul-threaded style="margin:1em 0pt 0pt -20px <span class=connect><span id=li1 class=li-threaded><span class=threaded><span style="position:static;border-left-width:3px" class="no-bg-color post-border post-middle <span id=post18878959 style="display:block _________________________________________________________________________
#include "mex.h"
#include <iostream>
class addLib {
private:
public:
addLib();
double add(double* v1, double* v2);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
};
addLib::addLib() {}
void addLib::mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
double *a, *b;
a = mxGetPr(prhs[0]);
b = mxGetPr(prhs[1]);
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); // Works
double* result = (double*) mxGetPr(plhs[0]);
result[0] = add(a,b);
}
double addLib::add(double* v1, double* v2) {
return v1[0] + v2[0];
}
_________________________________________________________________________
Using Tatsuros guide I had previously set up a compiler that was able to compile this code. Anyway, compilation went through and was entirely
successful. I can run addLib from Octave without a problem and debug it
as well.
Unfortunately, the next step was more of a problem.
I created a c++ file called incl in a project called inclMex.
_________________________________________________________________________
#include "C
ocuments and SettingsbkirklinSVNtrunkoctaveSRCaddLib.cpp"
#include <stdio.h>
int main() {
printf("Hello");
double *a, *b, *res;
addLib *ab = new addLib();
a[0] = 1;
b[0] = 1;
printf("%d",ab->add(a,b));
return 0;
}
_________________________________________________________________________
After adding several paths to the linker into Octaves inerds,
I was able to get this to compile without a fault detected. Then I
began receiving errors when running the program. At first it complained
about not being able to find the Octave dlls. So I copied them all into
the same location as my .exe. Then it complained about windows dlls. So
I copied all of those. Heres the resulting collection of files located
in my debug directory:
_________________________________________________________________________
[.] libjasper-1.dll
[..] libjpeg-62.dll
ATL80.dll liblapack.dll
cruft.dll libMagick++-10.dll
gluegen-rt.dll libMagick-10.dll
inclMex.exe libncurses-5.dll
inclMex.exp libnetcdf-4.dll
inclMex.ilk libpango-1.0-0.dll
inclMex.lib libpangocairo-1.0-0.dll
inclMex.pdb libpangowin32-1.0-0.dll
jogl.dll libpcre-0.dll
jogl_awt.dll libpng13.dll
jogl_cg.dll libportaudio-2.dll
libarpack.dll libreadline-5.dll
libblas.dll libtiff.dll
libbz2.dll libwmflite-0-2-7.dll
libcairo-2.dll libxml2-2.dll
libcurl.dll mfc80.dll
libfftw3-3.dll mfc80u.dll
libfreetype-6.dll mfcm80.dll
libgd-2.dll mfcm80u.dll
libglib-2.0-0.dll Microsoft.VC80.ATL.manifest
libglpk-0.dll Microsoft.VC80.CRT.manifest
libgmodule-2.0-0.dll Microsoft.VC80.MFC.manifest
libgobject-2.0-0.dll msvcm80.dll
libgsl-0.dll msvcp80.dll
libgslcblas-0.dll msvcr80.dll
libgthread-2.0-0.dll octave.dll
libhdf5-0.dll octinterp.dll
libiconv-2.dll zlib1.dll
libintl-8.dll
_________________________________________________________________________
Well, that effectively took care of all of the errors reflecting anything specific. The next
error said this: (appears 2xs)
"The application failed to initialize properly (0x80000003). Click Ok to terminate the aplication."
Further research led me to believe that this was the result of
either more missing dlls or a bad manifest file somewhere. Im not
sure, however, which manifest file is missing where or similarly which
dll. Im using Microsoft Visual Studios 2005 and the version of Octave
compiled with Microsoft Visual Studios 2005.
This page here seemed it might be of use, but did not result in any improvement:
../thread/eb134e02-5d32-44ae-aa26-c106c082c72a/" rel=nofollow>http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/eb134e02-5d32-44ae-aa26-c106c082c72a/
This
page seemed relevant as well, and seems to confirm my diagnoses of the
problem, but does not appear to have a solution to help me:
http://www.nabble.com/Re:-mkoctave-MSVC-2008-Express-td15912053.html http://www.nabble.com/Re:-mkoctave-MSVC-2008-Express-td15912053.html
As a side note, I tried to use an existing package, OctaveEmbedded, for similar reasons, ( http://wiki.octave.org/wiki.pl?OctaveEmbedded" rel=nofollow>http://wiki.octave.org/wiki.pl?OctaveEmbedded )
from Octave forge. I added its
files to my project and recieved the same error code after removing the
bit about addLib. So this problem appears to be of wider scope and just
what I was trying to do.
Its understandable if no one here has experience with octave or a solution as this isnt a microsoft product, but the failure seems to be one that occasionally crops for many different users who are doing similar things to myself. So anyway, any ideas or thoughts?
View the full article
"The application failed to initialize properly (0x80000003). Click on OK to terminate the application."
I understand it is unlikely to find anyone who knows much about Octave so I will try to fill you in as much as possible. This is where you can go to download the software if you are interested in it:
http://octave.sourceforge.net/
As stated, Im trying to compile code while using the library created by code used by Octave. In this case, Im trying to use what is called a .mex file. .Mex files are c++ code which can be called by Octave and also have the capability to call other Octave functions. They are compiled with a command mkoctfile --mex, which in turn calls the associated compiler. Instructions for setting up the compiler were found here: http://www.geocities.jp/tmoctwin/msvcoct.html
Anyway, I created a sample program to try to link to. It follows her (addLib.cpp):<span class=ul-threaded style="margin:1em 0pt 0pt -20px <span class=connect><span id=li1 class=li-threaded><span class=threaded><span style="position:static;border-left-width:3px" class="no-bg-color post-border post-middle <span id=post18878959 style="display:block <span class=ul-threaded style="margin:1em 0pt 0pt -20px <span class=connect><span id=li1 class=li-threaded><span class=threaded><span style="position:static;border-left-width:3px" class="no-bg-color post-border post-middle <span id=post18878959 style="display:block _________________________________________________________________________
#include "mex.h"
#include <iostream>
class addLib {
private:
public:
addLib();
double add(double* v1, double* v2);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
};
addLib::addLib() {}
void addLib::mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
double *a, *b;
a = mxGetPr(prhs[0]);
b = mxGetPr(prhs[1]);
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); // Works
double* result = (double*) mxGetPr(plhs[0]);
result[0] = add(a,b);
}
double addLib::add(double* v1, double* v2) {
return v1[0] + v2[0];
}
_________________________________________________________________________
Using Tatsuros guide I had previously set up a compiler that was able to compile this code. Anyway, compilation went through and was entirely
successful. I can run addLib from Octave without a problem and debug it
as well.
Unfortunately, the next step was more of a problem.
I created a c++ file called incl in a project called inclMex.
_________________________________________________________________________
#include "C

#include <stdio.h>
int main() {
printf("Hello");
double *a, *b, *res;
addLib *ab = new addLib();
a[0] = 1;
b[0] = 1;
printf("%d",ab->add(a,b));
return 0;
}
_________________________________________________________________________
After adding several paths to the linker into Octaves inerds,
I was able to get this to compile without a fault detected. Then I
began receiving errors when running the program. At first it complained
about not being able to find the Octave dlls. So I copied them all into
the same location as my .exe. Then it complained about windows dlls. So
I copied all of those. Heres the resulting collection of files located
in my debug directory:
_________________________________________________________________________
[.] libjasper-1.dll
[..] libjpeg-62.dll
ATL80.dll liblapack.dll
cruft.dll libMagick++-10.dll
gluegen-rt.dll libMagick-10.dll
inclMex.exe libncurses-5.dll
inclMex.exp libnetcdf-4.dll
inclMex.ilk libpango-1.0-0.dll
inclMex.lib libpangocairo-1.0-0.dll
inclMex.pdb libpangowin32-1.0-0.dll
jogl.dll libpcre-0.dll
jogl_awt.dll libpng13.dll
jogl_cg.dll libportaudio-2.dll
libarpack.dll libreadline-5.dll
libblas.dll libtiff.dll
libbz2.dll libwmflite-0-2-7.dll
libcairo-2.dll libxml2-2.dll
libcurl.dll mfc80.dll
libfftw3-3.dll mfc80u.dll
libfreetype-6.dll mfcm80.dll
libgd-2.dll mfcm80u.dll
libglib-2.0-0.dll Microsoft.VC80.ATL.manifest
libglpk-0.dll Microsoft.VC80.CRT.manifest
libgmodule-2.0-0.dll Microsoft.VC80.MFC.manifest
libgobject-2.0-0.dll msvcm80.dll
libgsl-0.dll msvcp80.dll
libgslcblas-0.dll msvcr80.dll
libgthread-2.0-0.dll octave.dll
libhdf5-0.dll octinterp.dll
libiconv-2.dll zlib1.dll
libintl-8.dll
_________________________________________________________________________
Well, that effectively took care of all of the errors reflecting anything specific. The next
error said this: (appears 2xs)
"The application failed to initialize properly (0x80000003). Click Ok to terminate the aplication."
Further research led me to believe that this was the result of
either more missing dlls or a bad manifest file somewhere. Im not
sure, however, which manifest file is missing where or similarly which
dll. Im using Microsoft Visual Studios 2005 and the version of Octave
compiled with Microsoft Visual Studios 2005.
This page here seemed it might be of use, but did not result in any improvement:
../thread/eb134e02-5d32-44ae-aa26-c106c082c72a/" rel=nofollow>http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/eb134e02-5d32-44ae-aa26-c106c082c72a/
This
page seemed relevant as well, and seems to confirm my diagnoses of the
problem, but does not appear to have a solution to help me:
http://www.nabble.com/Re:-mkoctave-MSVC-2008-Express-td15912053.html http://www.nabble.com/Re:-mkoctave-MSVC-2008-Express-td15912053.html
As a side note, I tried to use an existing package, OctaveEmbedded, for similar reasons, ( http://wiki.octave.org/wiki.pl?OctaveEmbedded" rel=nofollow>http://wiki.octave.org/wiki.pl?OctaveEmbedded )
from Octave forge. I added its
files to my project and recieved the same error code after removing the
bit about addLib. So this problem appears to be of wider scope and just
what I was trying to do.
Its understandable if no one here has experience with octave or a solution as this isnt a microsoft product, but the failure seems to be one that occasionally crops for many different users who are doing similar things to myself. So anyway, any ideas or thoughts?
View the full article