I'm trying to implement calling octave from C, as per the example shown in this answer Call GNU Octave functions in C?
I'm trying this in Nebeans on Linux.
I've created the files calloctave.cc, calloctave.h, main.c and myfunction.m as per the example. Pointed the links and includes to the correct places (in my case /usr/include/octave-5.2.0/octave/ and /usr/lib64/octave/5.2.0 ). I've chosen C++11 as the standard. In the code, there are no errors highlighted and it seems to find everything it needs, and nothing is highlighted as missing.
When I try to compile it, I just get a series of errors as follows....
cd '/home/arwel/NetBeansProjects/callOctave_new'
/bin/gmake -f Makefile CONF=Debug
"/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/arwel/NetBeansProjects/callOctave_new'
"/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/libcallOctave_new.so
gmake[2]: Entering directory `/home/arwel/NetBeansProjects/callOctave_new'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/calloctave.o.d"
g++ -c -g -I/usr/include/octave-5.2.0/octave -include /usr/include/octave-5.2.0/octave/mex.h -std=c++11 -fPIC -MMD -MP -MF "build/Debug/GNU-Linux/calloctave.o.d" -o build/Debug/GNU-Linux/calloctave.o calloctave.cc
In file included from /usr/include/octave-5.2.0/octave/Cell.h:33:0,
from /usr/include/octave-5.2.0/octave/gtk-manager.h:32,
from /usr/include/octave-5.2.0/octave/interpreter.h:36,
from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov.h:52:7: error: using typedef-name ‘mxArray’ after ‘class’
class mxArray;
^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a previous declaration here
typedef void mxArray;
^
In file included from /usr/include/octave-5.2.0/octave/ov.h:62:0,
from /usr/include/octave-5.2.0/octave/Cell.h:33,
from /usr/include/octave-5.2.0/octave/gtk-manager.h:32,
from /usr/include/octave-5.2.0/octave/interpreter.h:36,
from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov-base.h:57:7: error: using typedef-name ‘mxArray’ after ‘class’
class mxArray;
^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a previous declaration here
typedef void mxArray;
^
calloctave.cc: In function ‘int mexCallOctave(int, mxArray**, int, mxArray**, const char*)’:
calloctave.cc:26:15: error: ‘mxArray’ is not a class, namespace, or enumeration
args(i) = mxArray::as_octave_value (argin[i]);
^
calloctave.cc:42:41: error: invalid use of ‘mxArray {aka void}’
argout[i] = new mxArray (retval(i));
^
calloctave.cc: In function ‘void free_arg_list(int, mxArray**)’:
calloctave.cc:56:29: warning: deleting ‘mxArray* {aka void*}’ is undefined [enabled by default]
delete arglist[i];
^
gmake[2]: *** [build/Debug/GNU-Linux/calloctave.o] Error 1
gmake[2]: Leaving directory `/home/arwel/NetBeansProjects/callOctave_new'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/arwel/NetBeansProjects/callOctave_new'
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
It seems to be not understanding the mex interface in some way. I'm not very knowledgeable about C/C++, so am at a loss as to how to proceed here. What could be causing these errors and how might I resolve them?
Related
Downloaded 5.0.5 from Redis
cd to src directory
make
Surely this must work for someone else out there. Any idea/ hintg about how to fix this?
Short version:
In net.c ...
make[3]: Entering directory '/cygdrive/c/Users/pmoran/Downloads/redis-5.0.5/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
net.c:270:21: error: storage size of ‘hints’ isn’t known
struct addrinfo hints, *servinfo, *bservinfo, *p, *b;
^~~~~
and later
net.c:337:40: error: dereferencing pointer to incomplete type ‘struct addrinfo’
for (p = servinfo; p != NULL; p = p->ai_next) {
^~
then
make[3]: *** [Makefile:156: net.o] Error 1
make[3]: Leaving directory '/cygdrive/c/Users/pmoran/Downloads/redis-5.0.5/deps/hiredis'
make[2]: *** [Makefile:46: hiredis] Error 2
make[2]: Leaving directory '/cygdrive/c/Users/pmoran/Downloads/redis-5.0.5/deps'
and finally
cc: error: ../deps/hiredis/libhiredis.a: No such file or directory
cc: error: ../deps/lua/src/liblua.a: No such file or directory
make[1]: *** [Makefile:219: redis-server] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/pmoran/Downloads/redis-5.0.5/src'
make: *** [Makefile:6: all] Error 2
I had the same exact problem and I found the best solution was to use an older version of redis. Redis 3.2.13 was updated recently (March 2019) so it has all the functionality I need. If you use it, you do have to add the following to redis-3.2.13/deps/hiredis/net.c after the 'include' statements:
#ifdef __CYGWIN__
#define TCP_KEEPCNT 8
#define TCP_KEEPINTVL 150
#define TCP_KEEPIDLE 14400
#endif
After that I was able to run make from the root directory:
make distclean
make
This is based on this github conversation.
Hope this helps!
You can have a try.
Step 1:
Remove segment '-std=c99' from line
$(CC) -std=c99 -pedantic -c $(REAL_CFLAGS) $<
in file Makefile under .\redis-5.0.5\deps\hiredis
Ste 2:
Add the following segment after includes deps/hiredis/net.c after the 'include' statements:
#ifndef TCP_KEEPCNT
#define TCP_KEEPCNT 8
#endif
#ifndef TCP_KEEPINTVL
#define TCP_KEEPINTVL 150
#endif
#ifndef TCP_KEEPIDLE
#define TCP_KEEPIDLE 14400
#endif
I followed these instructions. Download lmbench3.tar.gz from lmbench3
and Unpack LMbench to create a tree like so:
lmbench/
Results/
doc/
scripts/
src/
And Go to the lmbench directory, and type make results see
But the result is wrong:
7 warnings generated.
gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_uint64_t=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -c getopt.c -o ../bin/i686-apple-darwin15.6.0/getopt.o
gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_uint64_t=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -c lib_sched.c -o ../bin/i686-apple-darwin15.6.0/lib_sched.o
lib_sched.c:94:3: error: non-void function 'handle_scheduler' should return a
value [-Wreturn-type]
return;
^
1 error generated.
make[2]: *** [../bin/i686-apple-darwin15.6.0/lib_sched.o] Error 1
make[1]: *** [lmbench] Error 2
make: *** [build] Error 2
How to solve it?
You can change the statement
return;
into
return 0;
at line 94 of lib_sched.c
Then this file should compile without this error.
I just started Learn C the Hard Way and I'm on Exercise #2.
link here:
http://c.learncodethehardway.org/book/ex2.html
The instructions are to make a file with only this in it:
CFLAGS=-Wall -g
clean:
rm -f ex1
So I created and saved that as Makefile.c, however, upon running it as specified in my compiler (MINGW), I'm getting this error:
$make clean
cc makefile.c -o makefile
makefile.c:3:1: warning: data definition has no type or storage class [enabled by default]
makefile.c:3:9: error: 'Wall' undeclared here (not in a function)
makefile.c:3:15: error: 'g' undeclared here (not in a function)
makefile.c:5:1: error expected ',' or ';' before 'clean'
cc Makefile.c -o Makefile
Makefile.c:3:1: warning: data definition has no type or storage class [enabled by default]
Makefile.c:3:9: error: 'Wall' undeclared here (not in a function)
Makefile.c:3:15: error: 'g' undeclared here (not in a function)
Makefile.c:5:1: error expected ',' or ';' before 'clean'
make: *** No rule to make target 'clean'. Stop.
Any ideas what I'm doing wrong and/or how I can fix this? Thanks!
Late, but your makefile should just be named "Makefile"
Makefile is not the source code for a C program, but a set of instructions for the Makefile tool, which gets used when you type "make foo".
Makefile can be called "makefile" or "Makefile"
According to man make:
"Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) The first name checked, GNUmakefile, is not recommended for most makefiles."
Are you using tab characters instead of space? The web page has spaces, but a makefile needs tabs. Note the author's comment after the makefile code.
I have floowing directory structure for gstraemer sources
/home/dev/cerbero/sources/linux_x86_64/gst-plugins-bad-0.10.23
when i run .autogen.sh it runs fine
but when i do "make"
it gives follwing error
gst-plugins_bad_compile_error
more specifically
Making all in gst
make[2]: Entering directory `/home/dev/cerbero/sources/linux_x86_64/gst-plugins- bad-0.10.23/gst'
make -C adpcmdec
make[3]: Entering directory `/home/dev/cerbero/sources/linux_x86_64/gst-plugins-bad-0.10.23/gst/adpcmdec'
CC libgstadpcmdec_la-adpcmdec.lo
adpcmdec.c:586:21: error: expected declaration specifiers or '...' before '(' token
adpcmdec.c:586:40: error: expected declaration specifiers or '...' before '(' token
adpcmdec.c:586:59: error: unknown type name 'adpcmdec'
adpcmdec.c:587:5: error: expected declaration specifiers or '...' before string constant
adpcmdec.c:587:22: error: expected declaration specifiers or '...' before 'plugin_init'
adpcmdec.c:587:35: error: expected declaration specifiers or '...' before string constant
adpcmdec.c:587:44: error: expected declaration specifiers or '...' before string constant
adpcmdec.c:587:52: error: expected declaration specifiers or '...' before string constant
adpcmdec.c:588:5: error: expected declaration specifiers or '...' before string constant
adpcmdec.c:576:1: warning: 'plugin_init' defined but not used [-Wunused-function]
make[3]: *** [libgstadpcmdec_la-adpcmdec.lo] Error 1
make[3]: Leaving directory `/home/dev/cerbero/sources/linux_x86_64/gst-plugins- bad-0.10.23/gst/adpcmdec'
make[2]: *** [adpcmdec] Error 2
make[2]: Leaving directory `/home/dev/cerbero/sources/linux_x86_64/gst-plugins-bad-0.10.23/gst'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/dev/cerbero/sources/linux_x86_64/gst-plugins-bad-0.10.23'
make: *** [all] Error 2
A few things before building
Did you install liboil and orc compiler?
Run ./configure --enable-orc if you did
Run ./configure if you did not
Then do a make
Remember to do a make distclean before you do the above steps or simply get clean source. Do not do this on the "dirty half built" folder directly.
It could also be a nasm/yasm issue though I doubt it.
EDIT: My suggestin is to install orc because that speeds up gstreamer by a lot!
I use Ubuntu 10.10 - 2.6.35.23-generic
I want to compile the lincan-module (http://sourceforge.net/projects/ocera/), but it doesn't work like I want... That's my first compilation of a kernel module. I did this:
First unzipped the lincan-sources to my home directory. Then excecuted "make" with this output:
make -C /home/x/can/lincan-0.3.4/src SOURCES_DIR=/home/x/can/lincan-0.3.4/src default ; make -C /home/x/can/lincan-0.3.4/utils SOURCES_DIR=/home/x/can/lincan-0.3.4/utils default ;
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory)
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory)
grep: /lib/modules/2.6.35-23-generic/build/include/linux/utsrelease.h: No such file or directory
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/src'
Makefile:216: /lib/modules/2.6.35-23-generic/build/Rules.make: No such file or directory
make[1]: *** Keine Regel, um »/lib/modules/2.6.35-23-generic/build/Rules.make« zu erstellen. Schluss.
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/src'
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/utils'
cc -I../include -O2 -Wall -c -o rxtx.o rxtx.c
rxtx.c: In function ‘main’:
rxtx.c:49: warning: format not a string literal and no format arguments
rxtx.c:73: warning: format not a string literal and no format arguments
rxtx.c:51: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
rxtx.c:58: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
rxtx.c:62: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
rxtx.c:67: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
rxtx.c:75: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
rxtx.c:81: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
cc rxtx.o -o rxtx
cc -I../include -O2 -Wall -c -o sendburst.o sendburst.c
cc sendburst.o -o sendburst
cc -I../include -O2 -Wall -c -o readburst.o readburst.c
cc readburst.o -o readburst
cc -I../include -O2 -Wall -c -o send.o send.c
send.c: In function ‘main’:
send.c:25: warning: format not a string literal and no format arguments
send.c:27: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
send.c:33: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
send.c:35: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
send.c:40: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
cc send.o -o send
cc -I../include -O2 -Wall can-proxy.c -o can-proxy
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/utils'
Then I type "make install":
make -C /home/x/can/lincan-0.3.4/src SOURCES_DIR=/home/x/can/lincan-0.3.4/src install ; make -C /home/x/can/lincan-0.3.4/utils SOURCES_DIR=/home/x/can/lincan-0.3.4/utils install ;
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory)
awk: cannot open /lib/modules/2.6.35-23-generic/build/include/linux/autoconf.h (No such file or directory)
grep: /lib/modules/2.6.35-23-generic/build/include/linux/utsrelease.h: No such file or directory
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/src'
Makefile:216: /lib/modules/2.6.35-23-generic/build/Rules.make: No such file or directory
make[1]: *** Keine Regel, um »/lib/modules/2.6.35-23-generic/build/Rules.make« zu erstellen. Schluss.
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/src'
make[1]: Betrete Verzeichnis '/home/x/can/lincan-0.3.4/utils'
echo Nothing to install
Nothing to install
make[1]: Verlasse Verzeichnis '/home/x/can/lincan-0.3.4/utils'
And it happend nothing. I find no kernel module. What did I wrong? Why is there no autoconf.h and the other files? Have you any hints for me? Thanks!
Now I created hardlinks for the missing files (autoconf.h and utsrelease.h). They are in /usr/src/linux-headers-2.6.35.23-generic/include/generated/
Now it compile much more. This is the first error that appears:
In file included from /home/x/can/lincan-0.3.4/src/../include/main.h:38,
from /home/x/can/lincan-0.3.4/src/proc.c:37:
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h: In function ‘canque_edge_decref’:
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: invalid initializer
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: invalid initializer
/home/x/can/lincan-0.3.4/src/../include/./can_queue.h:652: error: incompatible types when assigning to type ‘int’ from type ‘atomic_t’
make[3]: *** [/home/x/can/lincan-0.3.4/src/proc.o] Fehler 1
make[2]: *** [_module_/home/x/can/lincan-0.3.4/src] Fehler 2
make[2]: Verlasse Verzeichnis '/usr/src/linux-headers-2.6.35-23-generic'
make[1]: *** [make_this_module] Fehler 2
Now I created hardlinks for the missing files (autoconf.h and utsrelease.h).
You have to install the package that contains the build environment as created when the kernel you are running was built. Source is generally pointless (what do you want with, say, 8139too.c anyway when you are going to build an external module), save for the kernel headers. I can't say where the build environment is located in Debian or its offsprings, but in openSUSE there would be a "kernel-default-devel" package for example to contain utsrelease.h and autoconf.h, as well as - via dependencies - the static header files required. Thus, look for an preexisting deb package that contains this.
Please install kernel build prerequisites given here. This would install necessary tools for building/compiling the kernel modules.