Brandon
2012-07-15 19:38:24
Background:
- This tutorial will teach you how to compile Smart from its source.
- This will be useful if you decide to make your own changes to Smart or simply want to build it yourself.
- Building it yourself can solve many problems specific to your situation. One such problem is the socket not pairing. Compiling it yourself seems to be a work around for such a problem.
Requirements:
What you downloaded:
- Cross platform x32 and x64 compiler. If you use SEH instead of SJLJ, you will NOT be able to compile x32 code. SEH is better for x64 builds by a lot. However, since Simba uses x32 modules, we need SJLJ.
- Msys command-line is a shell that allows us to run unix/linux like commands on Windows.. grep, bash, make, etc..
- Java JDK is of course needed to compile Smart's java classes. JDK 6 is deprecated and JDK7 or JDK8+ must be used to compile the latest Smart.
- Smart's source is what we will be compiling using the above tools and environments.
Installing Mingw:
- Unzip the downloaded .7z file to the C drive.
- Rename the folder to mingw64.
Once done, it should look like the following:
[spoiler=ShowImages]

[/spoiler]Installing MSYS:
- Run the MSYS Installer and press yes on the Setup prompt.
- Click Next and then YES to the agreement.
- Click Next.
- Leave the path as: C:\msys\1.0 and click Next.
- Put a checkmark in the Don't create any icons check-box and click Next.
- Press install.
- After a second or two a command-line interface pops up and asks you: Do you wish to continue with the post install? [yn ]
- Type y and press Enter.
- It will now ask you: Do you have MinGW installed? [yn ].
- Type y and press Enter.
- Finally, it asks: Where is your MinGW installation?
- You will type: C:/Mingw64 and press Enter.
- Finally, press any key to continue…
- Uncheck the two boxes on the end of the screen and Finish the installation.
Lost or Confused?
See the following Image tutorial for the above steps:
[spoiler=ShowImages]









[/spoiler]Modifying the PATH environment variable:
Adding entries to the PATH is normally harmless. However, if you delete any existing entries, you may mess up your PATH, and you could compromise the functioning of your computer. Please be careful.
This part of the tutorial is ONLY if your Java installation is NOT configured properly. Follow along and check if it is. If it isn't you will need to make some changes as shown.
- Right-click Computer and click properties. Otherwise navigate to: Control Panel\System and Security\System
- Click Advanced system settings
- Click Environment Variables…
- Scroll down the System Variables panel, select the PATH variable and click Edit.
- Press Ctrl+A to select all and Copy paste it into a text editor.
- Check to see if 'Java' and 'Mingw' is in it by pressing Ctrl + F and typing Java and Ctrl + F and typing Mingw. —Modifications (Does NOT delete anything)—
- If Java or Mingw is missing, we will add them to the end of the path. Each path is separated by a semi-colon as shown below:
- If you are unsure, please see the images in the image tutorial below! You do NOT want to mess this up.
- When finished modifying the PATH, copy paste it from your text editor back into your environment variable. —Modification finished.—
- If all is well, click OK 3 times to exit all the interfaces and save any changes.
...OtherPaths...;C:\Mingw64\bin;C:\Program Files\Java\jdk1.8.0\bin
Lost or Confused?
See the following Image tutorial for the above steps:
[spoiler=ShowImages]




(DO NOT add split them into new lines like the below! It is just an illustration)

[/spoiler]Compiling Smart:
- Navigate to the folder containing SMART's source.
- Open the Makefile using a text editor.
- Change WIN_GPP to g++ and WIN64_GPP to g++ (This step may be confusing, if so see the images tutorial below or copy this makefile).
- Save your changes.
- Navigate to C:\msys\1.0
- Run msys.bat
- Change directory to Smart's source using the CD command. (cd "LocationOfSmart's source here" with quotes.)
- Run the make command. (make clean windows)
Lost or Confused?
See the following Image tutorial for the above steps:
[spoiler=ShowImages]




[/spoiler]Makefile I used: http://pastebin.com/raw.php?i=6uX3N8Eb
[spoiler=ShowMake]
# Copyright 2006-2013 by Benjamin J. Land (a.k.a. BenLand100)
#
# This file is part of the SMART Minimizing Autoing Resource Thing (SMART)
#
# SMART is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SMART is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SMART. If not, see <http://www.gnu.org/licenses/>.
#these compilers work with crossdev on gentoo
WIN_GPP=g++
WIN64_GPP=g++
LIN_GPP=i686-pc-linux-gnu-g++
LIN64_GPP=x86_64-pc-linux-gnu-g++
JAVAC=javac
JAR=jar
DIST=dist
BUILD=build
WIN_NAME=libsmartremote32.dll
WIN64_NAME=libsmartremote64.dll
LIN_NAME=libsmartremote32.so
LIN64_NAME=libsmartremote64.so
JNI_WIN_NAME=libsmartjni32.dll
JNI_WIN64_NAME=libsmartjni64.dll
JNI_LIN_NAME=libsmartjni32.so
JNI_LIN64_NAME=libsmartjni64.so
JAVA_NAME=smart.jar
WIN_COMPILE_ARGS=-DWINDOWS -O3 -s -m32 -c
WIN64_COMPILE_ARGS=-DWINDOWS -O3 -s -m64 -c
LIN_COMPILE_ARGS=-fPIC -DLINUX -O3 -s -c
LIN64_COMPILE_ARGS=-fPIC -DLINUX -O3 -s -c
SRC_DIR=src
LIN_BUILD_DIR=$(BUILD)/linux32
LIN64_BUILD_DIR=$(BUILD)/linux64
WIN_BUILD_DIR=$(BUILD)/windows32
WIN64_BUILD_DIR=$(BUILD)/windows64
JAVA_BUILD_DIR=$(BUILD)/java
CPPSOURCEFILES= \
$(SRC_DIR)/SmartRemote.cpp
JNI_CPPSOURCEFILES= \
$(SRC_DIR)/SmartJNI.cpp
CPPHEADERFILES= \
$(SRC_DIR)/SmartRemote.h \
$(SRC_DIR)/libsmartremote.def
JNI_CPPHEADERFILES= \
$(SRC_DIR)/jni.h \
WINOBJFILES= \
$(WIN_BUILD_DIR)/SmartRemote.o
JNI_WINOBJFILES= \
$(WIN_BUILD_DIR)/SmartJNI.o
WIN64OBJFILES= \
$(WIN64_BUILD_DIR)/SmartRemote.o
JNI_WIN64OBJFILES= \
$(WIN64_BUILD_DIR)/SmartJNI.o
LINOBJFILES= \
$(LIN_BUILD_DIR)/SmartRemote.o
JNI_LINOBJFILES= \
$(LIN_BUILD_DIR)/SmartJNI.o
LIN64OBJFILES= \
$(LIN64_BUILD_DIR)/SmartRemote.o
JNI_LIN64OBJFILES= \
$(LIN64_BUILD_DIR)/SmartJNI.o
JAVASOURCES= \
$(SRC_DIR)/Canvas.java \
$(SRC_DIR)/Main.java \
$(SRC_DIR)/BlockingEventQueue.java \
$(SRC_DIR)/Client.java \
$(SRC_DIR)/ClientStub.java \
$(SRC_DIR)/EventNazi.java \
$(SRC_DIR)/EventRedirect.java \
$(SRC_DIR)/UnblockedEvent.java
JAVACLASSES= \
$(JAVA_BUILD_DIR)/java/awt/Canvas.class \
$(JAVA_BUILD_DIR)/smart/Main.class \
$(JAVA_BUILD_DIR)/smart/BlockingEventQueue.class \
$(JAVA_BUILD_DIR)/smart/Client.class \
$(JAVA_BUILD_DIR)/smart/ClientStub.class \
$(JAVA_BUILD_DIR)/smart/EventNazi.class \
$(JAVA_BUILD_DIR)/smart/EventRedirect.class \
$(JAVA_BUILD_DIR)/smart/UnblockedEvent.class
all:
@echo "Syntax for the SMART makefile:"
@echo " For Windows distributions: make windows windows64"
@echo " For Linux distributions: make linux linux64"
@echo " For All distributions: make everything"
@echo " For test apps: make test-python test-linux test-linux64 test-windows test-windows64"
@echo " For all test apps: make test-all"
@echo " To clean build files: make clean"
everything: linux linux64 windows windows64
test-all: test-python test-windows test-windows64 test-linux test-linux64
linux: $(JAVACLASSES) $(DIST)/$(LIN_NAME) $(DIST)/$(JNI_LIN_NAME)
@echo "Finished Building the Linux 32bit SMART distribution"
linux64: $(JAVACLASSES) $(DIST)/$(LIN64_NAME) $(DIST)/$(JNI_LIN64_NAME)
@echo "Finished Building the Linux 64bit SMART distribution"
windows: $(JAVACLASSES) $(DIST)/$(WIN_NAME) $(DIST)/$(JNI_WIN_NAME)
@echo "Finished Building the Windows 32bit SMART distribution"
windows64: $(JAVACLASSES) $(DIST)/$(WIN64_NAME) $(DIST)/$(JNI_WIN64_NAME)
@echo "Finished Building the Windows 64bit SMART distribution"
test-linux:
@mkdir -p $(DIST)
@$(LIN_GPP) -I $(SRC_DIR) -fPIC -shared -s -o $(DIST)/example-plugin32.so test-apps/example-plugin.cpp
@$(LIN_GPP) -ldl -o $(DIST)/test-plugin-load32 test-apps/test-plugin-load.cpp
@$(LIN_GPP) -ldl -o $(DIST)/test-spawn32 test-apps/test-spawn.cpp
@$(LIN_GPP) -ldl -o $(DIST)/test-eios32 test-apps/test-eios.cpp
@$(LIN_GPP) -ldl -o $(DIST)/test-exports32 test-apps/test-exports.cpp
@echo "Finished building Linux 32bit test files"
test-linux64:
@mkdir -p $(DIST)
@$(LIN64_GPP) -I $(SRC_DIR) -fPIC -shared -s -o $(DIST)/example-plugin64.so test-apps/example-plugin.cpp
@$(LIN64_GPP) -ldl -o $(DIST)/test-plugin-load64 test-apps/test-plugin-load.cpp
@$(LIN64_GPP) -ldl -o $(DIST)/test-spawn64 test-apps/test-spawn.cpp
@$(LIN64_GPP) -ldl -o $(DIST)/test-eios64 test-apps/test-eios.cpp
@$(LIN64_GPP) -ldl -o $(DIST)/test-exports64 test-apps/test-exports.cpp
@echo "Finished building Linux 64bit test files"
test-windows:
@mkdir -p $(DIST)
@$(WIN_GPP) -I $(SRC_DIR) -shared -static-libgcc -static-libstdc++ -s -o $(DIST)/example-plugin32.dll test-apps/example-plugin.cpp
@$(WIN_GPP) -static-libgcc -static-libstdc++ -o $(DIST)/test-plugin-load32.exe test-apps/test-plugin-load.cpp
@$(WIN_GPP) -static-libgcc -static-libstdc++ -o $(DIST)/test-spawn32.exe test-apps/test-spawn.cpp
@$(WIN_GPP) -static-libgcc -static-libstdc++ -o $(DIST)/test-eios32.exe test-apps/test-eios.cpp
@$(WIN_GPP) -static-libgcc -static-libstdc++ -o $(DIST)/test-exports32.exe test-apps/test-exports.cpp
@echo "Finished building Windows 32bit test files"
test-windows64:
@mkdir -p $(DIST)
@$(WIN64_GPP) -I $(SRC_DIR) -shared -static-libgcc -static-libstdc++ -s -o $(DIST)/example-plugin64.dll test-apps/example-plugin.cpp
@$(WIN64_GPP) -static -static-libgcc -static-libstdc++ -o $(DIST)/test-plugin-load64.exe test-apps/test-plugin-load.cpp
@$(WIN64_GPP) -static -static-libgcc -static-libstdc++ -o $(DIST)/test-spawn64.exe test-apps/test-spawn.cpp
@$(WIN64_GPP) -static -static-libgcc -static-libstdc++ -o $(DIST)/test-eios64.exe test-apps/test-eios.cpp
@$(WIN64_GPP) -static -static-libgcc -static-libstdc++ -o $(DIST)/test-exports64.exe test-apps/test-exports.cpp
@echo "Finished building Windows 64bit test files"
test-python:
@mkdir -p $(DIST)
@cp test-apps/test-python.py $(DIST)/test-python
@echo "Finished building Python test files"
clean:
@echo "Cleaning build files..."
@rm -rf $(BUILD) $(DIST)
#### LINUX BUILDING DIRECTIVES ####
$(DIST)/$(LIN_NAME): $(LINOBJFILES)
@echo "Linking Linux Remote object files..."
@mkdir -p $(DIST)
@$(LIN_GPP) -fPIC -shared -s -o $(DIST)/$(LIN_NAME) $(LINOBJFILES)
$(DIST)/$(JNI_LIN_NAME): $(JNI_LINOBJFILES)
@echo "Linking Linux JNI object files..."
@mkdir -p $(DIST)
@$(LIN_GPP) -fPIC -shared -s -o $(DIST)/$(JNI_LIN_NAME) $(JNI_LINOBJFILES)
$(LIN_BUILD_DIR)/SmartRemote.o: $(SRC_DIR)/SmartRemote.cpp $(CPPHEADERFILES)
@echo "Compiling SmartRemote.cpp"
@mkdir -p $(LIN_BUILD_DIR)
@$(LIN_GPP) $(LIN_COMPILE_ARGS) -o $(LIN_BUILD_DIR)/SmartRemote.o $(SRC_DIR)/SmartRemote.cpp
$(LIN_BUILD_DIR)/SmartJNI.o: $(SRC_DIR)/SmartJNI.cpp $(JNI_CPPHEADERFILES)
@echo "Compiling SmartJNI.cpp"
@mkdir -p $(LIN_BUILD_DIR)
@$(LIN_GPP) $(LIN_COMPILE_ARGS) -o $(LIN_BUILD_DIR)/SmartJNI.o $(SRC_DIR)/SmartJNI.cpp
#### LINUX64 BUILDING DIRECTIVES ####
$(DIST)/$(LIN64_NAME): $(LIN64OBJFILES)
@echo "Linking Linux64 Remote object files..."
@mkdir -p $(DIST)
@$(LIN64_GPP) -fPIC -shared -s -o $(DIST)/$(LIN64_NAME) $(LIN64OBJFILES)
$(DIST)/$(JNI_LIN64_NAME): $(JNI_LIN64OBJFILES)
@echo "Linking Linux64 JNI object files..."
@mkdir -p $(DIST)
@$(LIN64_GPP) -fPIC -shared -s -o $(DIST)/$(JNI_LIN64_NAME) $(JNI_LIN64OBJFILES)
$(LIN64_BUILD_DIR)/SmartRemote.o: $(SRC_DIR)/SmartRemote.cpp $(CPPHEADERFILES)
@echo "Compiling SmartRemote.cpp"
@mkdir -p $(LIN64_BUILD_DIR)
@$(LIN64_GPP) $(LIN64_COMPILE_ARGS) -o $(LIN64_BUILD_DIR)/SmartRemote.o $(SRC_DIR)/SmartRemote.cpp
$(LIN64_BUILD_DIR)/SmartJNI.o: $(SRC_DIR)/SmartJNI.cpp $(JNI_CPPHEADERFILES)
@echo "Compiling SmartJNI.cpp"
@mkdir -p $(LIN64_BUILD_DIR)
@$(LIN64_GPP) $(LIN64_COMPILE_ARGS) -o $(LIN64_BUILD_DIR)/SmartJNI.o $(SRC_DIR)/SmartJNI.cpp
#### WINDOWS BUILDING DIRECTIVES ####
$(DIST)/$(WIN_NAME): $(WINOBJFILES)
@echo "Linking Windows Remote object files..."
@mkdir -p $(DIST)
@$(WIN_GPP) -Wl,$(SRC_DIR)/libsmartremote.def -static -static-libgcc -static-libstdc++ -mwindows -shared -s -m32 -o $(DIST)/$(WIN_NAME) $(WINOBJFILES) -lws2_32
$(DIST)/$(JNI_WIN_NAME): $(JNI_WINOBJFILES)
@echo "Linking Windows JNI object files..."
@mkdir -p $(DIST)
@$(WIN_GPP) -Wl,$(SRC_DIR)/libsmartjni.def -static -static-libgcc -static-libstdc++ -mwindows -shared -s -m32 -o $(DIST)/$(JNI_WIN_NAME) $(JNI_WINOBJFILES)
$(WIN_BUILD_DIR)/SmartRemote.o: $(SRC_DIR)/SmartRemote.cpp $(CPPHEADERFILES)
@echo "Compiling SmartRemote.cpp"
@mkdir -p $(WIN_BUILD_DIR)
@$(WIN_GPP) $(WIN_COMPILE_ARGS) -o $(WIN_BUILD_DIR)/SmartRemote.o $(SRC_DIR)/SmartRemote.cpp -lws2_32
$(WIN_BUILD_DIR)/SmartJNI.o: $(SRC_DIR)/SmartJNI.cpp $(JNI_CPPHEADERFILES)
@echo "Compiling SmartJNI.cpp"
@mkdir -p $(WIN_BUILD_DIR)
@$(WIN_GPP) $(WIN_COMPILE_ARGS) -o $(WIN_BUILD_DIR)/SmartJNI.o $(SRC_DIR)/SmartJNI.cpp
#### WINDOWS64 BUILDING DIRECTIVES ####
$(DIST)/$(WIN64_NAME): $(WIN64OBJFILES)
@echo "Linking Windows64 Remote object files..."
@mkdir -p $(DIST)
@$(WIN64_GPP) -Wl,$(SRC_DIR)/libsmartremote.def -static -static-libgcc -static-libstdc++ -mwindows -shared -s -m64 -o $(DIST)/$(WIN64_NAME) $(WIN64OBJFILES) -lws2_32
$(DIST)/$(JNI_WIN64_NAME): $(JNI_WIN64OBJFILES)
@echo "Linking Windows64 JNI object files..."
@mkdir -p $(DIST)
@$(WIN64_GPP) -Wl,$(SRC_DIR)/libsmartjni.def -static -static-libgcc -static-libstdc++ -mwindows -shared -s -m64 -o $(DIST)/$(JNI_WIN64_NAME) $(JNI_WIN64OBJFILES)
$(WIN64_BUILD_DIR)/SmartRemote.o: $(SRC_DIR)/SmartRemote.cpp $(CPPHEADERFILES)
@echo "Compiling SmartRemote.cpp"
@mkdir -p $(WIN64_BUILD_DIR)
@$(WIN64_GPP) $(WIN64_COMPILE_ARGS) -o $(WIN64_BUILD_DIR)/SmartRemote.o $(SRC_DIR)/SmartRemote.cpp -lws2_32
$(WIN64_BUILD_DIR)/SmartJNI.o: $(SRC_DIR)/SmartJNI.cpp $(JNI_CPPHEADERFILES)
@echo "Compiling SmartJNI.cpp"
@mkdir -p $(WIN64_BUILD_DIR)
@$(WIN64_GPP) $(WIN64_COMPILE_ARGS) -o $(WIN64_BUILD_DIR)/SmartJNI.o $(SRC_DIR)/SmartJNI.cpp
#### JAVA BUILDING DIRECTIVES ####
$(JAVACLASSES): $(JAVASOURCES)
@echo "Compiling Java Classes..."
@mkdir -p $(JAVA_BUILD_DIR)
@$(JAVAC) -classpath $(JAVA_BUILD_DIR) -sourcepath $(SRC_DIR) -d $(JAVA_BUILD_DIR) $(JAVASOURCES)
@echo "Creating JAR Archive..."
@mkdir -p $(DIST)
@$(JAR) cfe $(DIST)/$(JAVA_NAME) smart.Main -C $(JAVA_BUILD_DIR) .
[/spoiler]Your plugins and jar file should now be in the dist folder. Copy paste them to your C:/Simba/Plugins folder and enjoy.


730mb after just logging in to game. 32bit would only use 300mb+.