What to consider when using a Ruby extension with Rails? - c++

I want to make a C++ extension (that uses external libraries, namely stdlib and OpenCV) for Ruby, then bring that into a Rails project. Is there anything special I should do to make it compatible for Rails, or better yet, is there a Rails framework that makes writing extensions (especially for C++) easier?

Regardless of Rails you can create gems with C extensions.
I suggest you watch the RailsCast on how to create a gem:
http://railscasts.com/episodes/245-new-gem-with-bundler
And from there check the RubyGems tutorial on how to add C extensions
http://guides.rubygems.org/c-extensions/
I've never done a C++ extension, but EventMachine is built with C++
https://github.com/eventmachine/eventmachine

Related

Website project targeted to .NET 4.0 is picking up stuff from newer .NET versions

I have a ASP.NET WebSite project in my solution, there are other class library projects that are all targeted to .NET 4.0. It works fine on every developer's computer except for one.
Linq in .NET 4.0 did not have a Prepend extension method so we had created one ourselves, on one developer's computer the website crashes with a runtime error stating that the Prepend is ambigous between our namespace and Linq's namespace.
Prepend was first introduced in .NET 4.7.1 which we are not targeting. We checked the bin directory, System.Core.dll is 4.0. We checked all other DLLs' manifests to make sure they are dependent on System.Core 4.0.
What else do we need to check?
ASP.NET applications are compiled against directly against the files in the .NET Framework folder (i.e directly against the implementation). Since .NET Framework is an in-place update, newer versions of the Framework will overwrite the files already in the same folder.
One thing you could do is call your Prepend method directly (ie. fully qualified name) and not like an extension method.

Distributing ruby gems in a C/C++ GNU autotools project

I am working in a polyglot project which mostly uses C++ and for some high level tasks Ruby.
In my Ruby scripts I extensively used few very useful gems. However, although my Autotools setup is installing the ruby scripts, I do not find any way to distribute the required gems.
Do you know any idiom or way to deal with this issue?

How to include .NET framework library in executable

I've recently made a Windows Forms Application in VS 2010 Express. When running on my machine it works fine but on other machines it needs to install the .NET framework first. Is there anyway around this? By including the library in my executable? By not using the .NET framework?
I would really appreciate some help.
Typically this kind of problem would be handled by your Windows Forms Application's installation package.
Opinions vary but I'd suggest the safest/most polite thing to do is to treat .NET as a prerequisite. If .NET is not present, display a message that it is required before the install will succeed and perhaps point to a Microsoft download page like this one or this one. The risk is that you point them to an obsolete download page or that the page moves and invalidates your link.
That said, I would have expected most machines to have some version of the .NET Framework installed (by Windows Update for example) so it's a bit surprising that you're being told it needs to be installed.
I suggest you follow the instructions in How to: Determine Which .NET Framework Versions Are Installed to check one of your failing machines to confirm that .NET is not installed (very unlikely) or to determine which version (or versions) of .NET is (are) installed.
Update 6/21/2015 From the comment below, we have evidence of two systems without .NET installed so my "very unlikely" comment above is a bit off base!
Update 7/4/2015 I have a bad habit of forgetting that not everyone configures their Windows systems exactly the same way I configure mine. From this blog post it seems that the .NET Framework is 'only' a Recommended Update.

JNI in Blackberry10

I would like to know if it was possible to use JNI for an BB10 app. I'm kinda new with this thing and I saw somewhere that is possible.
Because I've an android app but I need to had some special features to make it run properly on BB10 and for that I need to use JNI.
Is it possible ? If yes, is it possible to find a sample or some doc about it somewhere ?
I assume you are asking about running an Android appliction on BB10. Support for JNI does not exist on any of the current official BB10 versions (up to and including 10.2.0). However version 10.2.1 includes a completely different Android runtime that is able to run APK directly including applications that use JNI. I haven't seen any official documentation of this yet however.

Question regarding libraries and framework

Sorry i'm a beginner,from what i know there are number of varieties of libraries and framework out there provided for the C++ language.My question is,when we create an application using the framework and libraries,do the users of the application need to install the framework or so so call the libraries on his/her PC??Thank You
It depends whether the library you are using is statically or dynamically linked. In the former case, it is part of the executable file that you distribute. In the latter case, it is an extra file (or set of files) with extensions such as .so or .dll, which you should distribute with your app.
Yes, libraries must be bundled with your application/installed before hand, as they are the framework upon which your application relies. If you don't install the framework, your application will not work.
You need to install something, not necessarily the framework. Some frameworks, like DirectX for example have a client installation. Some components are simple dll files that you can deliver with your software, creating an installation package.
The end-user need to have the framework installed.
As you need to have .Net installed to run some Microsoft(and other companies) products. If your application is written in C++ using GTK or Qt. You need to have they installed, but if you're on Linux using KDE, Qt is natively installed for default, the same for Gnome and also the same of Cocoa on Mac and Cocoa-Touch on iPhone and iPod Touch.
I suggest you to have the installer of the framework used embedded on the installer of your application. As GIMP and Xchat do.
Generally when using a framework there will be a framework redistributable (.NET, DirectX, etc) which can be bootstrapped into your installation to install the framework (or run by the end user as the first part of "installing" your app).
Many libraries simply need to be included with your code to function correctly, they themselves might have dependencies which need to be installed but these should be called out.
If in doubt, before you distribute your package run it on a fresh install of your target system (Linux, Windows, etc) and see if it complains about missing dependencies. Include those in your package and try again.
You can also look at installation systems (RPM, Apt, Windows Installer, etc) which can handle all of these tasks for you directly (or provide scripting languages to help you automate the job).