I've just upgraded my app from 1.8.7 to 1.9.2 using RVM and had to add RubyGems and Bundler, ran bundle install and got everything to work except SystemTimer. Google-fu returns nothing and I see others have had issue with it in 1.9 but some have gotten it to work. Any ideas?
pawel:bodb pawel$ sudo gem install SystemTimer
Building native extensions. This could take a while...
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
ERROR: Error installing SystemTimer:
ERROR: Failed to build gem native extension.
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
creating Makefile
make
/usr/bin/gcc-4.2 -I. -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.3.0
-I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I.
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers
-Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -o system_timer_native.o -c system_timer_native.c
In file included from system_timer_native.c:8:
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
system_timer_native.c: In function ‘install_first_timer_and_save_original_configuration’:
system_timer_native.c:46: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:53: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:57: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:62: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:65: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:69: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:82: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:89: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:96: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:101: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘install_next_timer’:
system_timer_native.c:112: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:119: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:123: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:130: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:136: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:143: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:146: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘restore_original_configuration’:
system_timer_native.c:157: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:160: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:168: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:170: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:172: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘restore_original_timer_interval’:
system_timer_native.c:190: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type
system_timer_native.c:192: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘restore_sigalrm_mask’:
system_timer_native.c:199: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:201: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘install_ruby_sigalrm_handler’:
system_timer_native.c:211: error: ‘rb_thread_critical’ undeclared (first use in this function)
system_timer_native.c:211: error: (Each undeclared identifier is reported only once
system_timer_native.c:211: error: for each function it appears in.)
system_timer_native.c: In function ‘restore_original_ruby_sigalrm_handler’:
system_timer_native.c:217: error: ‘rb_thread_critical’ undeclared (first use in this function)
system_timer_native.c: In function ‘clear_pending_sigalrm_for_ruby_threads’:
system_timer_native.c:266: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c: In function ‘set_itimerval’:
system_timer_native.c:290: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
system_timer_native.c:295: warning: implicit conversion shortens 64-bit value into a 32-bit value
system_timer_native.c:299: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type
make: *** [system_timer_native.o] Error 1
Gem files will remain installed in /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3 for inspection.
Results logged to /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3/ext/system_timer/gem_make.out
As far as I know, SystemTimer isn't relevant for ruby 1.9 and shouldn't use with this version.
"Using this gem in Ruby 1.9 is useless and does not make any sense! System Timer is trying to work around some limitation of the "green thread" model used in Ruby 1.8 (MRI). See http://ph7spot.com/musings/system-timer for more details."
A drop-in replacement for SystemTimer is timeout.rb from Ruby core. No need for any 3rd party gems.
Ruby 1.8:
require 'system_timer'
SystemTimer.timeout_after(5.minutes, MyException) do
# your job here
end
Ruby 1.9:
require 'timeout'
Timeout.timeout(5.minutes, MyException) do
# your job here
end
To install system timer use this command in Terminal:
sudo gem install system_timer
Related
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?
I got following warning while compiling on x86_64 gcc:
warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but
argument 2 has type ‘u64’
Both unsigned long long and u64 are 64-bit unsigned integer, aren't they?
So what is exactly the difference that gcc considers about them?
In short llu can be 64 bit but this is not a must. It all depends on the machine, compiler etc. You should consider using PRIu64 in your case.
Your question has already been answered in detail here: Link
I get a strange compiler warning when i use the reader-writer spinlock as below,
defined in a.c
struct rwloct_t rwspinlock.
rwlock_init(&rwspinlock);
using in b.c by declaring
extern struct rwloct_t rwspinlock
So, in b.c whenever i call lock or unlock, eg.read_rwlock(&rwspinlock) i get the below warning.
warning: passing argument 1 of ‘_raw_read_lock_bh’ from incompatible pointer type
/home/dev/data/linux/linux/include/linux/rwlock_api_smp.h:20: note: expected ‘struct rwlock_t *’ but argument is of type ‘struct rwlock_t *’
Then, I changed as below,
defined in a.c
struct rwloct_t rwspinlock.
rwlock_init(&rwspinlock);
declared in a.h
extern struct rwloct_t rwspinlock
included in b.c as,
#include "a.h"
Now there is no compilation warning. However, i'm unclear how!.
Can anybody explain, what exactly happened ?
Maybe your rwloct_t is already defined (typedef) as a struct (here the _t suffix)?
If so you don't need to use struct again:
rwloct_t rwspinlock;
extern rwloct_t rwspinlock;
Why it work within .h and not .c? I don't know, but you may try to precompile both with gcc and the option -E and see if there's some difference, else I guess is some compiler internal reason.
I have installed MPICH (ver 3.0.4) on my linux machine (CentOS 6.4) for doing some parallel computation. I tried to compile "pmandel.c" (which comes with MPICH installation package as an example) to test my MPICH installation with this command :
mpicc pmandel.c -o pmandel.out
but it returns these errors:
pmandel.c: In function ‘main’:
pmandel.c:279: warning: passing argument 2 of ‘bind’ from incompatible pointer type
/usr/include/sys/socket.h:115: note: expected ‘const struct sockaddr *’ but argument is of type ‘struct sockaddr_in *’
pmandel.c:282: warning: passing argument 2 of ‘bind’ from incompatible pointer type
/usr/include/sys/socket.h:115: note: expected ‘const struct sockaddr *’ but argument is of type ‘struct sockaddr_in *’
pmandel.c:296: warning: passing argument 2 of ‘getsockname’ from incompatible pointer type
/usr/include/sys/socket.h:119: note: expected ‘struct sockaddr * __restrict__’ but argument is of type ‘struct sockaddr_in *’
/tmp/cclNv8nA.o: In function `exponential_complex':
pmandel.c:(.text+0x2fc2): undefined reference to `exp'
pmandel.c:(.text+0x2fd1): undefined reference to `cos'
pmandel.c:(.text+0x2fe5): undefined reference to `sin'
/tmp/cclNv8nA.o: In function `absolute_complex':
pmandel.c:(.text+0x3330): undefined reference to `sqrt'
collect2: ld returned 1 exit status
and no output is made. I also tried with "mpic++", "mpiCC", mpicxx" ... but all to no avail.
what should I do to correct this?
#Spiros is correct that you need to add -lm to your mpicc. It matters where in the command you specify it, too.
"It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded."
see http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html.
It comes after pmandel.out.
mpicc pmandel.c -o pmandel.out -lm
Alternatively, you can use the Makefile included in the mpich examples directory and just type
make pmandel
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.