-
Notifications
You must be signed in to change notification settings - Fork 0
2.2 ‐ Publishing using Precompiled Exerb Header
In this article, I will show you how to pack all the Ruby codes of tswKai3 into one executable file so you can share it with others.
-
It is recommended to use Ruby 1.8.7, which is the last version officially supported by the original Exerb Project. This will save a lot of troubles, and even if you don't like it, you can always uninstall it later very easily.
-
Download and install Ruby 1.8.7.
Then, download the original, official Exerb 5.4.0. (If this link does not work out, try the archived webpage.)
Finally, unzip the file to any path, and run
ruby setup.rb
-
If you insist using a higher Ruby version...
- You will need to have a Devkit to compile C codes.
- RubyInstallers for Ruby < 2.4 come with a static Ruby library, which makes our compilation much easier. In this case, please refer to the guidelines in my forked
exerb-mingw
project. - For even higher Ruby versions, you will have to compile the static Ruby library from Ruby's source code, before you can compile
exerb-mingw
like above. - In these cases, you will want to include several more required files in the .exy YAML file when you pack the scripts into an executable. You can try
mkexy main.rbw
to get a sample .exy list to start with.
-
-
You will need the
win32/api
extension of either of the two forms below:-
Either: The official extension, by
gem install win32-api -v 1.5.3
(because this extension dropped support for Ruby 1.8 and 1.9 since version 1.6.0).Then, run the following code to locate the path of the
api.so
dynamic library:ruby -e "require 'rubygems'; require 'win32/api'; puts $LOADED_FEATURES.find {|i| i.include?('api.so')}"
Finally, make a new subfolder named
win32
under tswKai3's main folder, and copy the file located above to this new folder. -
Or: The modified extension (in order to solve the second issue in the Caveats section of the last article):
Follow the instructions in the second point in the Solutions section of the last article.
-
- The .exy YAML recipe file for packing the scripts is already provided:
tswKai3.exy
-
cd
to tswKai3's main folder, and runexerb tswKai3.exy
. That's it! Now you have a standalonetswKai3.exe
which you can share with others. - When you publish the executable file, make sure you provide the
tswKai3.exe.MANIFEST
file alongside with it, in order to solve the first issue in the Caveats section of the last article - Or, run
ruby compile\manifest.rb tswKai3.exe tswKai3.exe.MANIFEST
to incorporate the manifest as a resource within the executable, so you can get rid of the need of an additional, separate manifest file (and now it will become a "real standalone" executable).
- The Ruby codes are packed as plain-text data in the generated
tswKai3.exe
. It can be a drawback if you want to hide or compress the codes. - To achieve the idea of a "standalone executable," the
win32/api.so
dynamic library is packed intotswKai3.exe
, and it will be released to the user's temporary directory during the run time and then loaded. This behavior can be misinterpreted as malicious by some antivirus software.
Given the aforementioned issue, if you are still interested, let's discuss how to compress the Ruby codes, as well as how to statically link the win32/api
extension so as to avoid antivirus software's false positives, in the next article: Compiling from Scratch!
Copyright © 2020-2024 丁香园主人 (Z.Sun) tswKai3 Project