久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何從 ruby?? 中調(diào)用 C++ 函數(shù)

How can I call C++ functions from within ruby(如何從 ruby?? 中調(diào)用 C++ 函數(shù))
本文介紹了如何從 ruby?? 中調(diào)用 C++ 函數(shù)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我是一名經(jīng)驗(yàn)豐富的 C/C++ 開發(fā)人員,但我是 Ruby 的新手.

如何在 Ruby 中調(diào)用 C++ 函數(shù)?

解決方案

你有 3 種可能性:

1) Ruby 能夠加載庫(kù).即使有點(diǎn)棘手,您也可以決定編寫自己的加載程序并在 Ruby 中綁定您的 C++ 庫(kù).這是使用所謂的擴(kuò)展模塊完成的.您可以在此處找到綜合教程:http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html

2) 您可以使用工具來圍繞您的 C++ 庫(kù)生成 Ruby 包裝器.以 SWIG 為例(http://www.swig.org/).您只需要以特定于 swig 的語法創(chuàng)建一個(gè)文件并將其提供給 SWIG.然后它將能夠?yàn)榘?Ruby 在內(nèi)的多種語言生成包裝器.

3) 您可以選擇使用中間件,例如 CORBA/ICE/whatever.如果你只想調(diào)用一些 C++ 函數(shù)可能有點(diǎn)矯枉過正,但它可以讓你遠(yuǎn)程調(diào)用這些函數(shù),或者在中間件后面隱藏"一個(gè)網(wǎng)格.

I am an experienced C/C++ developer but I am a novice in Ruby.

How can I call a C++ function from with in Ruby?

解決方案

You have 3 possibilities :

1) Ruby is able to load libraries. Even if it is a bit tricky, you can decide to write your own loader and bind your C++ library in Ruby. This is done using what is called an extension module. You will find a comprehensive tutorial here: http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html

2) You can use a tool that will generate the Ruby wrapper around your C++ library. Look at SWIG for example (http://www.swig.org/). You just have to create a file in a swig-specific syntax and provide it to SWIG. It will then be able to generate the wrapper for many languages, Ruby included.

3) You can choose to use a middleware, such as CORBA/ICE/whatever. It may be a bit overkill if you only want to call some C++ functions, but it will allow you to remote call the functions, or "hide" a grid behind the middleware.

這篇關(guān)于如何從 ruby?? 中調(diào)用 C++ 函數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

boost_1_60_0 .zip installation in windows(Windows 中的 boost_1_60_0 .zip 安裝)
How do I get console output in C++ with a Windows program?(如何使用 Windows 程序在 C++ 中獲得控制臺(tái)輸出?)
How do I calculate the week number given a date?(如何計(jì)算給定日期的周數(shù)?)
OpenCV with Network Cameras(帶有網(wǎng)絡(luò)攝像機(jī)的 OpenCV)
Export all symbols when creating a DLL(創(chuàng)建 DLL 時(shí)導(dǎo)出所有符號(hào))
Getting started with OpenCV 2.4 and MinGW on Windows 7(Windows 7 上的 OpenCV 2.4 和 MinGW 入門)
主站蜘蛛池模板: 成年人免费看视频 | 日本黄色免费网站 | 日韩成人一区 | 高潮一区二区三区乱码 | 久久都是精品 | 成人午夜激情视频 | 黄色免费观看视频 | 成人爱爱 | 国产精品成人一区二区网站软件 | 国产又粗又大又硬 | 在线观看h视频 | 日日干av | 福利片国产 | 欧美三级三级三级爽爽爽 | 亚洲欧美一区二区三区在线 | √天堂资源地址在线官网 | 免费av网站在线观看 | 日本在线看片 | 国产一区二区福利 | 欧美一级黄色片 | 日本免费黄色 | 久久精品免费观看 | 欧美一级淫片 | 四虎黄色片 | 五月网站 | 久久91视频 | 福利在线观看 | 久久人人视频 | 天天看天天爽 | 99精品网站| 久久久久久久久国产精品 | 男女无遮挡xx00动态图120秒 | 人人超碰人人 | 国产欧美一区二区精品忘忧草 | 日韩精品视频免费在线观看 | 麻豆av在线免费观看 | 久久久久久久 | 日本在线视频一区 | 欧美国产日韩一区二区 | 欧美黑人一区二区三区 | 国产精品久久久久久亚洲影视 |