From: Nilbert Nullingsworth on 20 Jan 2010 20:00 Hey guys, I am extending ruby in a C++ program. I have all the headers set up and stuff so it compiles without error, but I do get one warning (MSVC Express 2008): c:\visual studio 2008\projects\remoteexec\remoteexec\rubyheaders\ruby/ missing.h(154) : warning C4273: 'vsnprintf' : inconsistent dll linkage C:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(350) : see previous definition of 'vsnprintf' Because it doesn't keep it from compiling, I don't think this is the source of my problem. The problem is, when I call ruby_init() to start the interpreter, the program instantly terminates. Run by the command line, it looks like this: C:\Visual Studio 2008\Projects\remoteExec\Release>project.exe C:\Visual Studio 2008\Projects\remoteExec\Release> As you can see, it does nothing. There are no errors, even though my code is wrapped in a try/catch thing. Here is the C++ Code: #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <cstdio> #include <cstdlib> #include <iostream> #include "ruby.h" using namespace std; int main() { //copied from teh internetz /*HWND hWnd = GetConsoleWindow(); ShowWindow(hWnd, SW_HIDE);*/ try { ruby_init(); } catch (char* e) { cout << e; } system("PAUSE"); return 0; } This code isn't supposed to do anything, it's just confining the error to that one line. No error is outputted and the program does not pause after executing the try/catch, like it should with system("PAUSE"). Does anyone know why it is just stopping the program when ruby_init() is called? I am using the ruby 1.9 libs and headers and stuff.
From: Nilbert Nullingsworth on 20 Jan 2010 20:03 Also as you can see, I have commented out the code that would have stopped the console window from displaying, as I thought it may have been the source of the problem. However, as evidenced by the command line and the fact that no process that belongs to the program is running, the program is indeed ceasing to exist upon reaching the ruby_init(); line.
From: Nilbert Nullingsworth on 20 Jan 2010 20:13 Actually, placing ruby_init() anywhere in the file closes the program instantly. Replacing the try/catch block above with this one: try { printf("ARGGGGGGGGGGGGGGGGGG"); printf("asdf"); ruby_init(); } catch (char* e) { printf("%s", e); } and running the program via command line does not print anything. What the heck. Anyone have any idea why the bloody blazes this is happening?
From: Eric Christopherson on 20 Jan 2010 20:39 On Wed, Jan 20, 2010 at 7:15 PM, Nilbert Nullingsworth <yakahughes(a)gmail.com> wrote: > Actually, placing ruby_init() anywhere in the file closes the program > instantly. Replacing the try/catch block above with this one: > > try { > printf("ARGGGGGGGGGGGGGGGGGG"); > > printf("asdf"); > > ruby_init(); > } catch (char* e) { > printf("%s", e); > } > > and running the program via command line does not print anything. > What the heck. Anyone have any idea why the bloody blazes this is > happening? > > No idea, but I got it to run smoothly when compiled with MinGW (for what little it's worth).
From: Nilbert Nullingsworth on 20 Jan 2010 20:55
Well, I may just have to learn how to use MinGW if no one can figure out why VC++ is messing it up. |