Ruby's native header files are giving me an error - ruby

When I include in my native C extension for a gem that I am writing, I get the following error:
../../../../ext/my_file/my_file.c:4:42: error: unknown type name 'RUBY_T_FIXNUM'
Here is where I use it in my code:
#include <stdlib.h>
#include <ruby-2.3.0/ruby.h>
void my_file_init(const T_STRING prog, T_FIXNUM verbose) {}
I added a link in /usr/local/include to ~/.rvm/rubies/default/include/ruby-2.3.0, which is where I have the version of ruby that I want to use installed. The only definition I could find for the T_FIXNUM constant in the ruby header files was within an enum in ruby/ruby.h:
enum ruby_value_type {
...
RUBY_T_FIXNUM = 0x15
};
Here is where the ruby/ruby.h file defines the T_FIXNUM type:
#define T_FIXNUM RUBY_T_FIXNUM
Am I including files incorrectly? Do I have the wrong version of Ruby? I'm working on OSX and I use RVM to manage my rubies. I have added symbolic links for config.h in the x86_64-darwin16/ruby dir, as well as a link from the ruby dir to itself.

Related

How do I correctly set up WXWidgets on Ubuntu? My editor tells me the header files are incorrect

I wanted to try out the WXWidgets Hello World example (https://docs.wxwidgets.org/latest/overview_helloworld.html) so I followed the recommended practice on the Downloads page and installed the WXGTK package for my distribution, Ubuntu, which appears to be libwxgtk3.0-gtk3-dev. After doing this, and copying the example code, g++ (installed from build-essentials) throws an error when I attempt to compile the program:
wxtest.cpp:4:10: fatal error: wx/wxprec.h: No such file or directory
4 | #include <wx/wxprec.h>
| ^~~~~~~~~~~~~
compilation terminated.
My editor (VSCode) also shows me an error: cannot open source file "wx/wxprec.h".
This appears to be related to the fact that the WXWidgets header files are installed to the folder wx-3.0/wx instead of wx, but after changing #include <wx/wxprec.h> to #include <wx-3.0/wx/wxprec.h> I still get an error:
In file included from wxtest.cpp:4:
/usr/include/wx-3.0/wx/wxprec.h:12:10: fatal error: wx/defs.h: No such file or directory
12 | #include "wx/defs.h"
| ^~~~~~~~~~~
compilation terminated.
What am I doing wrong? How can these files be put in the right place?
See the building your project section of the docs.

How to fix "error: no member named 'fancy_abort' in namespace 'std::__1'; did you mean simply 'fancy_abort'? _VSTD::abort();"

Platform: Macos Catalina 10.15.2
Xcode version: Xcode 11
I have tried many times to make-all gcc to build my source code. However, I have encountered a problem:
In file included from ../.././gcc/c/c-objc-common.c:33:
In file included from /Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/new:85:
/Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/exception:181:5: error:
no member named 'fancy_abort' in namespace 'std::__1'; did you mean simply 'fancy_abort'?
_VSTD::abort();
^~~~~~~ /Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:873:15: note:
expanded from macro '_VSTD' # _VSTD std::_LIBCPP_ABI_NAMESPACE
^ ../.././gcc/system.h:685:13: note: 'fancy_abort' declared here extern void fancy_abort (const char *, int, const char
*) ATTRIBUTE_NORETURN;
^
1 error generated.
make[1]: *** [c/c-objc-common.o] Error 1
make: *** [all-gcc] Error 2
I have tried to install another version of Xcode. I have installed Xcode6 but it still did not work, and I found a solution of this issue. But when I download Xcode8.3.3, it is not compatible with Catalina 10.15.2.
I ran in to this issue while using crosstools-ng on mac (mojave 10.14) to compile cross-platform toolchain with gcc 4.9.
Solution: Edit .build/src/gcc-4.9.4/gcc/system.h to add #include <map> in #ifdef __cplusplus block where other include statements are.
The problem is that is included (via ) after abort has been
defined as a macro to fancy_abort. And thus when the C++ standard headers try
to call std::abort, they end up calling std::fancy_abort, which of course
doesn't exist.
Source: https://gcc.gnu.org/legacy-ml/gcc-bugs/2017-09/msg00154.html

Qt5 application compiles on Linux and Windows, but gives cryptic error on Mac OS X

I work on a small open source pc timer project. I'd love to get my client working on OS X, but I can even get it to launch! I installed xcode, and the qt5 sdk with qtcreator. When I compile I get the following warnings, but the binary compiles:
/Users/kylehall/Documents/Libki/main.cpp:25: In file included from ../Libki/main.cpp:25:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
/Users/kylehall/Documents/Libki/timerwindow.cpp:21: In file included from ../Libki/timerwindow.cpp:21:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
/Users/kylehall/Documents/build-Libki-Desktop_Qt_5_2_1_clang_64bit-Debug/moc_timerwindow.cpp:9: In file included from moc_timerwindow.cpp:9:
/Users/kylehall/Documents/Libki/timerwindow.h:20: warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
#ifndef TIMERWINDOW_H
^~~~~~~~~~~~~
/Users/kylehall/Documents/Libki/timerwindow.h:21: 'LOGINWINDOW_H' is defined here; did you mean 'TIMERWINDOW_H'?
#define LOGINWINDOW_H
^~~~~~~~~~~~~
TIMERWINDOW_H
When I try to run the binary I get the following error:
dyld: Library not loaded: /work/build/______________________________PADDING______________________________/lib/QtPositioning.framework/Versions/5/QtPositioning
Referenced from: /Users/kylehall/Documents/build-Libki-Desktop_Qt_5_2_1_clang_64bit-Debug/libkiclient.app/Contents/MacOS/libkiclient
Reason: image not found
Debugging has finished
At this point I don't even know where to begin with such a cryptic error. Any suggestions would be great! You can grab the code and try compiling it yourself from https://bitbucket.org/libki-kms/libki-client/src
Seems pretty clear:
warning: 'TIMERWINDOW_H' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
So you must have:
#ifndef TIMERWINDOW_H
#define LOGINWINDOW_H
Copy and paste error, I'd say...

stray '#' in program

I want to use NSRunningApplication in my Qt application on Mac OS X.
I tried to include these header files in mainwindow.cpp:
#include Cocoa/Cocoa.h
#include Foundation/Foundation.h
#include AppKit/NSRunningApplication.h
#include AppKit/NSWorkspace.h
#include ApplicationServices/ApplicationServices.h
#include "CGWindow.h".
Also included following in .pro file
INCLUDEPATH += /System/Library/Frameworks/Foundation.framework/Headers
But this gives error: stray '#' in program
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6,
/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:8 : error: stray '#' in program.
My question is:
How to use NSRunningApplication in my application?
Which file(s) to include and where/how to remove these errors?
You need to make an objc file instead. Change the extension to .mm and use objc directive to import framework:
#import <Foundation/Foundation.h>

how to get kernel header file?

i'm trying to make new system calls in kernel 2.6.21
and one of the new system calls use 'sys_write' function,
but to use this function, i realized that i must install kernel header file according to 2.6.21 version.
but i can't find kernel header file(2.6.21)
i tried apt-get install linux-headers-'uname -r' , apt-cache search linux-headers-$(uname -r)
but i can't find anything..
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/fcntl.h>
#include <asm/uaccess.h>
int main(){
int fd;
int old_fs;
old_fs = get_fs();
set_fs(KERNEL_DS);
fd = sys_open("config.txt", O_RDONLY, 0);
if(fd >= 0)
sys_close(fd);
set_fs(old_fs);
return 0;
}
vv.c:2:24: error: linux/init.h: No such file or directory
vv.c:3:26: error: linux/module.h: No such file or directory
vv.c:4:28: error: linux/syscalls.h: No such file or directory
In file included from /usr/include/asm/fcntl.h:1,
from /usr/include/linux/fcntl.h:4,
from vv.c:5:
/usr/include/asm-generic/fcntl.h:120: error: expected specifier-qualifier-list before ‘off_t’
/usr/include/asm-generic/fcntl.h:143: error: expected specifier-qualifier-list before ‘loff_t’
vv.c:6:25: error: asm/uaccess.h: No such file or directory
vv.c: In function ‘main’:
vv.c:12: error: ‘KERNEL_DS’ undeclared (first use in this function)
vv.c:12: error: (Each undeclared identifier is reported only once
vv.c:12: error: for each function it appears in.)
additionally, above header files is what i want to.
how can i get the kernel header file?
please help me..
Did installing the headers complete? If so then they should be installed in /usr/include and the include directives you gave should just work.
Edit:
First run:
sudo apt-get update
To make sure you have the latest packages, then:
sudo apt-get install linux-headers-$(uname -r)
This is the one package that should contain all the kernel header files in Ubuntu.

Resources