# Compiling .c code using mkoctfile

 Classic List Threaded
6 messages
Reply | Threaded
Open this post in threaded view
|

## Compiling .c code using mkoctfile

 Hello,I am trying to use mkoctfile to compile some .c source code. When I try to do this, this message appears:C:\Octave\OCTAVE~1.1\include\octave-4.4.1\octave/Array.h:30:10: fatal error: cassert: No such file or directory #include I read some of the Octave support groups and it seems that this is because I can't #include Octave headers in the source code. It isn't clear to me if there is a good work around. Has anyone encountered this and worked out a fix for how to easily compile .c code using mkoctfile?Thank you!-Colin
Reply | Threaded
Open this post in threaded view
|

## Re: Compiling .c code using mkoctfile

 Hi, > On 6 Dec 2018, at 00:27, Colin Kikuchi <[hidden email]> wrote: > > Hello, > I am trying to use mkoctfile to compile some .c source code. When I try to do this, this message appears: > > C:\Octave\OCTAVE~1.1\include\octave-4.4.1\octave/Array.h:30:10: fatal error: cassert: No such file or directory >  #include This #include statement is meant for C++ not C. > I read some of the Octave support groups and it seems that this is because I can't #include Octave headers in the source code. It isn't clear to me if there is a good work around. Has anyone encountered this and worked out a fix for how to easily compile .c code using mkoctfile? Octave libraries are in C++, not C, so you cannot include their headers in your C code and compile with a C compiler. Depending on what you want to do, you can either * compile your C code with a C++ compiler (the easiest way to do so is  to rename it to .cc instead of .c) * access Octave libraries via the mex interface (which is a Matlab compatible C API) as explained here : https://octave.org/doc/interpreter/Mex_002dFiles.html#Mex_002dFiles> Thank you! > > -Colin Hope this helps, if you need more in-depth help you should provide more info, or share the .c code you are trying to compile. c.
Reply | Threaded
Open this post in threaded view
|

## Re: Compiling .c code using mkoctfile

 Hey Carlo, Thank you for your response! I tried compiling to an mex file based on the link you sent, using "mkoctfile --mex mexADIconf.c", but got the same error. I am attaching an example of the code I am trying to compile (there are several other programs like this one) in hopes that you or someone else might be able to give me a tip about compiling into an octfile. Sorry, I am a bit inexperienced with Octave so would really appreciate any suggestions you might have!Thanks again!-ColinOn Wed, Dec 5, 2018 at 11:18 PM Carlo De Falco <[hidden email]> wrote:Hi, > On 6 Dec 2018, at 00:27, Colin Kikuchi <[hidden email]> wrote: > > Hello, > I am trying to use mkoctfile to compile some .c source code. When I try to do this, this message appears: > > C:\Octave\OCTAVE~1.1\include\octave-4.4.1\octave/Array.h:30:10: fatal error: cassert: No such file or directory >  #include This #include statement is meant for C++ not C. > I read some of the Octave support groups and it seems that this is because I can't #include Octave headers in the source code. It isn't clear to me if there is a good work around. Has anyone encountered this and worked out a fix for how to easily compile .c code using mkoctfile? Octave libraries are in C++, not C, so you cannot include their headers in your C code and compile with a C compiler. Depending on what you want to do, you can either * compile your C code with a C++ compiler (the easiest way to do so is  to rename it to .cc instead of .c) * access Octave libraries via the mex interface (which is a Matlab compatible C API) as explained here : https://octave.org/doc/interpreter/Mex_002dFiles.html#Mex_002dFiles > Thank you! > > -Colin Hope this helps, if you need more in-depth help you should provide more info, or share the .c code you are trying to compile. c. mexADIconf.c (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

## Re: Compiling .c code using mkoctfile

 > On 6 Dec 2018, at 17:57, Colin Kikuchi <[hidden email]> wrote: > > Hey Carlo, > Thank you for your response! I tried compiling to an mex file based on the link you sent, using "mkoctfile --mex mexADIconf.c", but got the same error. I am attaching an example of the code I am trying to compile (there are several other programs like this one) in hopes that you or someone else might be able to give me a tip about compiling into an octfile. Sorry, I am a bit inexperienced with Octave so would really appreciate any suggestions you might have! > > Thanks again! > > -Colin Compiling your code I see the following : \$ mkoctfile -mex mexADIconf.c mexADIconf.c:37:10: warning: non-portable path to file ''; specified path differs in case from file name on disk       [-Wnonportable-include-path] #include          ^~~~~~~~~~           In file included from mexADIconf.c:37: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/matrix.h:31: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/mx-base.h:30: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/MatrixType.h:29: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/MSparse.h:29: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/Array-util.h:28: /opt/octave/4.4.0/include/octave-4.4.0/octave/Array.h:30:10: fatal error: 'cassert' file not found #include          ^~~~~~~~~ 1 warning and 1 error generated. The first message is just a warning as on macos files are not case sensitive the same would be an error on Linux. The second one is because you are including directly matrix.h from liboctave which includes cassert which is C++. Just comment out the unnecessary includes and all should work: /* header */ #include //#include //#include //#include HTH, c.
Reply | Threaded
Open this post in threaded view
|

## Re: Compiling .c code using mkoctfile

 Hey Carlo,Thanks, this is very helpful! Sorry to keep bugging you, but as a follow-up question, I have tried compiling with mkoctfile after commneting out the header information. Now, Octave is saying that 'mwSize' is an unknown type name:mexADIconf.c:44:14: error: unknown type name 'mwSize'              mwSize nz, mwSize nr, mwSize nper, mwSize *nt, double *dt,My understanding is that mwSize is a type name defining the size of arrays. Is there something I have to add to get Octave to recognize this, or should I call it something else?Thanks again!-ColinOn Thu, Dec 6, 2018 at 10:24 AM Carlo De Falco <[hidden email]> wrote: > On 6 Dec 2018, at 17:57, Colin Kikuchi <[hidden email]> wrote: > > Hey Carlo, > Thank you for your response! I tried compiling to an mex file based on the link you sent, using "mkoctfile --mex mexADIconf.c", but got the same error. I am attaching an example of the code I am trying to compile (there are several other programs like this one) in hopes that you or someone else might be able to give me a tip about compiling into an octfile. Sorry, I am a bit inexperienced with Octave so would really appreciate any suggestions you might have! > > Thanks again! > > -Colin Compiling your code I see the following : \$ mkoctfile -mex mexADIconf.c mexADIconf.c:37:10: warning: non-portable path to file ''; specified path differs in case from file name on disk       [-Wnonportable-include-path] #include          ^~~~~~~~~~           In file included from mexADIconf.c:37: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/matrix.h:31: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/mx-base.h:30: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/MatrixType.h:29: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/MSparse.h:29: In file included from /opt/octave/4.4.0/include/octave-4.4.0/octave/Array-util.h:28: /opt/octave/4.4.0/include/octave-4.4.0/octave/Array.h:30:10: fatal error: 'cassert' file not found #include          ^~~~~~~~~ 1 warning and 1 error generated. The first message is just a warning as on macos files are not case sensitive the same would be an error on Linux. The second one is because you are including directly matrix.h from liboctave which includes cassert which is C++. Just comment out the unnecessary includes and all should work: /* header */ #include //#include //#include //#include HTH, c.
Reply | Threaded
Open this post in threaded view
|

## Re: Compiling .c code using mkoctfile

 Il giorno ven 7 dic 2018, 04:04 Colin Kikuchi <[hidden email]> ha scritto:Hey Carlo,Thanks, this is very helpful! Sorry to keep bugging you, but as a follow-up question, I have tried compiling with mkoctfile after commneting out the header information. Now, Octave is saying that 'mwSize' is an unknown type name:mexADIconf.c:44:14: error: unknown type name 'mwSize'              mwSize nz, mwSize nr, mwSize nper, mwSize *nt, double *dt,My understanding is that mwSize is a type name defining the size of arrays. Is there something I have to add to get Octave to recognize this, or should I call it something else?Thanks again!-ColinHi,In my previous mail I wrote which headers you would need to comment Did you follow the hint or just comment out everything?I see the file you sent is part of some package developed at University of Ghent, does the package have its own makefile or some other form of automated build?Are you a developer of maxsym trying to port to Octave or a user trying to install it for yourself? In the latter case did you try to contact the developers?c.