Compile Ruby extension Library

Source: Internet
Author: User

 
# Loads mkmf which is used to make makefiles for Ruby extensions require 'mkmf '# Give it a name extension_name = 'fsnet' dirs = ["/usr/local/lib"] $ libs + = "-Levent" $ libs + = "-levent_extra" $ libs + = "-levent_pthreads" $ libs + = "-ljemalloc" $ cflags + = "-I/usr/ include "$ cflags + ="-I/usr/local/include "$ cflags + ="-I/usr/local/include/jemalloc "$ ldflags + ="-l/ usr/lib "$ ldflags + ="-l/usr/local/lib "# The destination dir_config (extension_name) # Do the work create_makefile (extension_name)


Create such a file first.

In fact, it is easy to understand.

It is nothing more than marking the connection library to be connected

Then Mark the path of the header file and Library File

Then create_makefile is ready.


Then

Ruby extconf. Rb

If no error occurs, the MAKEFILE file is automatically generated in the current path.

Then make Ruby's C library is generated.

You can use make install globally.


Then, pay attention to the following in the Code:

There must be one

 
Void init_fsnet ()
Such a function prototype.

It will be called at the first initialization.

You can define classes and functions in this function.




Compile Ruby extension Library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.