I am just messing around with Ruby and its internals. I am embedding
Ruby but without using the library, I directly link the .c files of
Ruby with my program. I got it working with the same code as I used
for my program which uses the static library.
The only problem I have is concerning the load path (I am just using
ruby_incpush here) :
- with static lib : [".", "lib"]
- without lib : [".\000", "lib\000"]
The consequence of that is that require does not find any file
anymore. Although, I am not sure if require works correctly either
because when ruby_init_loadpath, the load path contains "." but does
not load files.
I would like some advice if anyone already had this kind of problem
either with or without linking with the library. Thanks.
I took further tests :
- it works perfectly under Ubuntu 8.04 and GCC 4.1
- fails (with a big crash) with GCC 4.1 (MinGW)
I really have no clue why this does not work. I tried to play with the
stack reserve (in VS.net) but it didn't work. I thought maybe it's
because I mix C/C++ in the binary (yes, I'm really desperate to have
So a little summary of the problem :
I want to embed Ruby but instead of using the library (.lib or .a and/
or .so or .dll) I link the .c of Ruby directly. This does work (it
created a proper binary) but has problems with the load path and/or
Any message will be taken into account. Thanks.
OK, nobody helped in any way, but I found out why it did that.
The win32 function CharNext has 2 versions ANSI or Unicode and
when you create a project in VS.net it's Unicode by default.
If Unicode is chosen, the function becomes CharNextW which
passes over the null characters because it may detect them as
valid unicode characters.
This function is in ruby.c in push_include used by ruby_incpush.
A cross-platform solution is to replace the line 196, in ruby.c :
for (s = p; *s && *s != sep; s = CharNext(s));
for (s = p; *s && *s != sep; ++s);
because s is "const char*" anyway so there is no need for CharNext.
How do I file a bug for Ruby?
PS : I'm using Ruby 1.8.7-p22