-
Notifications
You must be signed in to change notification settings - Fork 21
Compiling
Here is a simple guide for you to compiling trojan plus, but it's for CentOS, you can modify it for your own system.
Check your gcc version first, if your system is low then CentOS 8, it may show:
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright © 2015 Free Software Foundation, Inc.
It's smaller than 7.0, so you need upgrade your dev tools:
yum install centos-release-scl -y
yum install devtoolset-8 -y
scl enable devtoolset-8 bash
This one of upgrade gcc ways, you can google another way to make sure your gcc version is higher than 7.0.
curl -LO https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --openssldir=/etc/ssl enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp no-idea no-dtls no-dtls1 no-shared no-psk no-srp no-ec2m no-weak-ssl-ciphers
make install_sw
cd ..
rm -rf openssl-1.1.1g.tar.gz openssl-1.1.1g
curl -LO https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz
tar xvf cmake-3.17.0.tar.gz
cd cmake-3.17.0
./bootstrap --
make -j$(nproc) install
cd ..
rm -rf cmake-3.17.0.tar.gz cmake-3.17.0
curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.gz
tar xvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh
./b2 -j$(nproc) --with-system --with-program_options variant=release link=static threading=multi runtime-link=shared install
cd ..
rm -rf boost_1_73_0.tar.gz boost_1_73_0
If you want to use original trojan's mysql recording feature, you need to compiling this mysqlclient dependency:
curl -LO https://downloads.mariadb.org/f/connector-c-3.1.7/mariadb-connector-c-3.1.7-src.tar.gz
tar xf mariadb-connector-c-3.1.7-src.tar.gz
cd mariadb-connector-c-3.1.7-src
echo "TARGET_LINK_LIBRARIES(libmariadb pthread)" >> libmariadb/CMakeLists.txt
cmake -DWITH_CURL=OFF -DWITH_DYNCOL=OFF -DWITH_MYSQLCOMPAT=ON -DWITH_UNIT_TESTS=OFF .
make -j$(nproc) install
cd ..
rm -rf mariadb-connector-c-3.1.7-src.tar.gz mariadb-connector-c-3.1.7-src
Now, you can git clone trojan plus project and compile it:
git clone --recurse-submodules https://github.com/Trojan-Plus-Group/trojan-plus.git
cd trojan-plus
mkdir build
cd build
# without mysql
cmake -DENABLE_MYSQL=OFF -DFORCE_TCP_FASTOPEN=ON -DBoost_USE_STATIC_LIBS=ON ..
# or with mysql
# cmake -DMYSQL_INCLUDE_DIR=/usr/local/include/mariadb -DMYSQL_LIBRARY=/usr/local/lib/mariadb/libmysqlclient.a -DFORCE_TCP_FASTOPEN=ON -DBoost_USE_STATIC_LIBS=ON ..
make
make install
Download Visual Studio 2019 Community version and install for C/C++ developer (all C/C++ components)
Download and click it to install a path you can find and remember easily, can be in D:\OpenSSL-Win64
Then download boost 1.73 for windows and decompress it, compile with following cmd:
cd <boost_dir>
bootstrap.bat
b2 --with-system --with-program_options variant=release link=static threading=multi runtime-link=shared
Download cmake 3+ for windows, you can choose standardalone version to avoid install. Please remember the install/decompress directory, can be in D:\cmake-3.17.2-win64-x64.
git clone --recurse-submodules https://github.com/Trojan-Plus-Group/trojan-plus.git
cd trojan-plus
md build
cd build
<cmake-dir>\bin\cmake -DBoost_INCLUDE_DIR="<boost_dir>" -DBoost_USE_STATIC_LIBS=ON -DOPENSSL_ROOT_DIR='<OpenSSL-Dir>' -DOPENSSL_USE_STATIC_LIBS=ON -DENABLE_MYSQL=OFF ..
<cmake-dir>\bin\cmake --build . --config Release
The executable binary file should be in trojan-plus\build\Release.
At first you should download the letest XCode from AppStore.
Then open terminal app and input following command to install boost and openssl dependence libraries :
brew install boost openssl@1.1 cmake
And then git clone trojan plus and compile:
git clone --recurse-submodules https://github.com/Trojan-Plus-Group/trojan-plus.git
cd trojan-plus
md build
cd build
cmake -DBoost_USE_STATIC_LIBS=ON -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.a -DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.a -DENABLE_MYSQL=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 ..
make
strip -SXTx trojan
If you want to compile with mysqlclient, please cmake:
cmake -DBoost_USE_STATIC_LIBS=ON -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.a -DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.a -DENABLE_MYSQL=ON -DMYSQL_INCLUDE_DIR=/usr/local/include/mariadb -DMYSQL_LIBRARY=/usr/local/lib/mariadb/libmysqlclient.a -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 ..
You can use -DENABLE_MYSQL=OFF to disable compile with mysqlclient, if want to add please set include/libs dir for cmake.
If you meet some link error such as:
CMakeFiles/trojan.dir/src/core/config.cpp.o: In function Config::prepare_ssl_context(boost::a sio::ssl::context&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<ch ar> >&)': config.cpp:(.text+0xb97): undefined reference to SSL_CTX_set_keylog_callback'
config.cpp:(.text+0xc4b): undefined reference to `SSL_CTX_set_ciphersuites'
collect2: error: ld returned 1 exit status
These "ld returned 1 exit status error" tell you some symbols cannot be found (undefined reference), please set a explicit path for it. These paths might not be same in each different system.
Above error information said, some SSL symbols cannot be found, so you need to add a path for openssl.
Inlucde dir path means directories contains a lot of *.h files, libraries path means a directories contains some *.a, *.so files, these folders can be found when you compile and install openssl/boost/libmysqlclient.
-
Windows:
-DOPENSSL_ROOT_DIR='D:/OpenSSL-Win64'
-
Linux:
-DOPENSSL_ROOT_DIR=/usr/local/include/openssl -DOPENSSL_LIBRARIES=/usr/local/include/openssl/lib
-
MacOS:
-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.a -DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.a
-
Windows:
-DBoost_INCLUDE_DIR="E:/boost_1_73_0"
-
Linux/MacOS:
-DBoost_INCLUDE_DIR=/usr/local/include/ -DBoost_LIBRARIES=/usr/local/include/boost/lib
-
Windows:
<Cannot be supported>
-
Linux/MacOS:
-DMYSQL_INCLUDE_DIR=/usr/local/include/mariadb -DMYSQL_LIBRARY=/usr/local/lib/mariadb/libmysqlclient.a