# 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