Closed MQSDREAM closed 4 years ago
Sorry for my guide wiki. You can choose:
1, disable mysql by
cmake -DENABLE_MYSQL=OFF ..
or 2, add(append) below line in CMakeLists.txt:
target_link_libraries(trojan dl)
when you change any compiling environments, please delete all contents cmake generated:
cd build
cmake .....
# change something, CMakeLists.txt or others
rm -rf *
cmake ....
please set paths of openssl for compiling:
cmake -DFORCE_TCP_FASTOPEN=ON -DENABLE_MYSQL=OFF -DOPENSSL_ROOT_DIR=/usr/local/include/openssl -DOPENSSL_LIBRARIES=/usr/local/include/openssl/lib ..
why disable mysql
which line append target_link_libraries(trojan dl) to ?
And every I changed some something, I deleted all in build and cmake again
Cmake can find openssl correctly without DOPENSSL_ROOT_DIR
root@SickProfuse-VM:/usr/workspace/trojan-plus/build# 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 ..
-- The CXX compiler identification is GNU 8.1.0
-- The C compiler identification is GNU 8.1.0
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
dl
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.73.0/BoostConfig.cmake (found suitable version "1.73.0", minimum required is "1.66.0") found components: system program_options
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "1.1.1g", minimum required is "1.1.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/workspace/trojan-plus/build
And I want to compile a armv8 version, I need change gcc to arm-linux-musleabi and use static library what change I need to do in CMakeLists.txt
1, disable mysql ,does not work
original CMakeLists.txt with cmake as following
cmake -DFORCE_TCP_FASTOPEN=ON -DENABLE_MYSQL=OFF -DOPENSSL_ROOT_DIR=/usr/local/include/openssl -DOPENSSL_LIBRARIES=/usr/local/include/openssl/lib -DBoost_USE_STATIC_LIBS=ON ..
-- The CXX compiler identification is GNU 8.1.0
-- The C compiler identification is GNU 8.1.0
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.73.0/BoostConfig.cmake (found suitable version "1.73.0", minimum required is "1.66.0") found components:
system program_options
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "1.1.1g", minimum required is "1.1.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/workspace/trojan-plus/build
errors as following
[100%] Linking CXX executable trojan
CMakeFiles/trojan.dir/src/core/config.cpp.o: In function Config::prepare_ssl_context(boost::asio::ssl::context&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': 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
CMakeFiles/trojan.dir/build.make:944: recipe for target 'trojan' failed
make[2]: [trojan] Error 1
CMakeFiles/Makefile2:92: recipe for target 'CMakeFiles/trojan.dir/all' failed
make[1]: [CMakeFiles/trojan.dir/all] Error 2
Makefile:157: recipe for target 'all' failed
make: *** [all] Error 2
root@SickProfuse-VM:/usr/workspace/trojan-plus/build#
please use following option to set a explicit .a file path for openssl and rm -rf try again:
-DOPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.a
-DOPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.a
the path might different in you system, please ls them first. maybe, your libssl.a file is miss.
trojan-plus fully supported, please use
./make_android.sh <android_ndk_root_path>
it works, thankyou I don't want to compile a andoid version I want to use trojan on my router ASUS GT-AC5300 so i need a arm linux version, and what change I need to do in CMakeLists.txt
change gcc to arm-linux-musleabi and use static library, or something else
I added environment variables to change complier as following, it work on amd64 version
export CC=/usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
export CXX=/usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++
I added target_link_libraries(trojan dl) at the end of CMakeLists.txt Cmake as following, it work on amd64 version
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 -DOPENSSL_CRYPTO_LIBRARY=/usr/local/lib64/libcrypto.a -DOPENSSL_SSL_LIBRARY=/usr/local/lib64/libssl.a ..
-- The CXX compiler identification is GNU 9.3.0
-- The C compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++
-- Check for working CXX compiler: /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
-- Check for working C compiler: /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.73.0/BoostConfig.cmake (found suitable version "1.73.0", minimum required is "1.66.0") found components: system program_options
-- Found OpenSSL: /usr/local/lib64/libcrypto.a (found suitable version "1.1.1g", minimum required is "1.1.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/workspace/trojan-plus/gt5300_build
But new issue shows up
/usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a(cmdline.o): Relocations in generic ELF (EM: 62) /usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a: error adding symbols: file in wrong format collect2: error: ld returned 1 exit status CMakeFiles/trojan.dir/build.make:946: recipe for target 'trojan' failed make[2]: [trojan] Error 1 CMakeFiles/Makefile2:92: recipe for target 'CMakeFiles/trojan.dir/all' failed make[1]: [CMakeFiles/trojan.dir/all] Error 2 Makefile:157: recipe for target 'all' failed make: *** [all] Error 2
If you want to compile trojan-plus in any arm platform (not in Android), please make sure boost and openssl can be compiled in that arm platform firstly.
You can refer Android libraries compiling: https://github.com/Trojan-Plus-Group/trojan-plus-android-libs
I just check your cmake compiling information:
/usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a(cmdline.o): Relocations in generic ELF (EM: 62) /usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a: error adding symbols: file in wrong format
it seems you haven't compiled boost in your arm platform, libboost_program_options.a is wrong format. I haven't compile boost libs by myself, I just refer this Boost for Android github https://github.com/moritz-wundke/Boost-for-Android.git
I have checked this github repo more or less, it changes boost sources before compiling, is not use boost's source directly.
If you want to compile trojan-plus in any arm platform (not in Android), please make sure boost and openssl can be compiled in that arm platform firstly.
You can refer Android libraries compiling: https://github.com/Trojan-Plus-Group/trojan-plus-android-libs
I just check your cmake compiling information:
/usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a(cmdline.o): Relocations in generic ELF (EM: 62) /usr/local/aarch64-linux-musl-cross/bin/../lib/gcc/aarch64-linux-musl/9.3.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/lib/libboost_program_options.a: error adding symbols: file in wrong format
it seems you haven't compiled boost in your arm platform, libboost_program_options.a is wrong format. I haven't compile boost libs by myself, I just refer this Boost for Android github https://github.com/moritz-wundke/Boost-for-Android.git
I have checked this github repo more or less, it changes boost sources before compiling, is not use boost's source directly.
thank you I have found the way to cross compile the boost But have no idea about openssl
Almost all systems provide openssl, because wget, curl, yum, apt, need it for STL/SSL connections.
you can use following command to check:
openssl --version
As long as this version is greater than 1.1.0, you can use installing utils of your system, such as yum, apt-get, pacman and so on to install openssl-devel or libopenssl or other name component, it might install in
/usr/include /usr/lib or /usr/lib64
or
/usr/local/include /usr/local/lib
two of *.a fils that trojan plus need are libssl.a and libcrypt.a, please find them firstly.
Almost all systems provide openssl, because wget, curl, yum, apt, need it for STL/SSL connections.
you can use following command to check:
openssl --version
As long as this version is greater than 1.1.0, you can use installing utils of your system, such as yum, apt-get, pacman and so on to install openssl-devel or libopenssl or other name component, it might install in
/usr/include /usr/lib or /usr/lib64
or
/usr/local/include /usr/local/lib
two of *.a fils that trojan plus need are libssl.a and libcrypt.a, please find them firstly.
can I disable the ....../cmake/Boost-1.73.0 only use the libs and the includes in trojan-plus-android-libs ? I have annotated the ....../cmake/Boost-1.73.0 in CMakeCache.txt, but it does not work. It still uses the system default ....../cmake/Boost-1.73.0 And compile fail
Almost all systems provide openssl, because wget, curl, yum, apt, need it for STL/SSL connections.
you can use following command to check:
openssl --version
As long as this version is greater than 1.1.0, you can use installing utils of your system, such as yum, apt-get, pacman and so on to install openssl-devel or libopenssl or other name component, it might install in
/usr/include /usr/lib or /usr/lib64
or
/usr/local/include /usr/local/lib
two of *.a fils that trojan plus need are libssl.a and libcrypt.a, please find them firstly.
I try to set Boost_SYSTEM_LIBRARY_RELEASE=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a/libboost_system.a mannual , but it does not work, cmake still check the system default version Cmake and error information as following
cmake -DENABLE_MYSQL=OFF -DFORCE_TCP_FASTOPEN=ON -DBoost_USE_STATIC_LIBS=ON -DOPENSSL_LIBRARIES=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a -DOPENSSL_CRYPTO_LIBRARY=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a/libcrypto.a -DOPENSSL_SSL_LIBRARY=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a/libssl.a -DBoost_INCLUDE_DIR=/usr/workspace/trojan-plus/trojan-plus-android-libs/include/boost -DBoost_LIBRARIES=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a -DBoost_PROGRAM_OPTIONS_LIBRARY_RELEASE=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a/libboost_program_options.a -DBoost_SYSTEM_LIBRARY_RELEASE=/usr/workspace/trojan-plus/trojan-plus-android-libs/lib/armeabi-v7a/libboost_system.a ..
-- The CXX compiler identification is GNU 9.3.0 -- The C compiler identification is GNU 9.3.0 -- Check for working CXX compiler: /usr/local/arm-linux-musleabi-cross/bin/arm-linux-musleabi-g++ -- Check for working CXX compiler: /usr/local/arm-linux-musleabi-cross/bin/arm-linux-musleabi-g++ - works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/local/arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc -- Check for working C compiler: /usr/local/arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc - works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE CMake Error at /usr/local/lib/cmake/Boost-1.73.0/BoostConfig.cmake:141 (find_package): Found package configuration file:
/usr/local/lib/cmake/boost_system-1.73.0/boost_system-config.cmake
but it set boost_system_FOUND to FALSE so package "boost_system" is considered to be NOT FOUND. Reason given by package:
No suitable build variant has been found.
The following variants have been tried and rejected:
Call Stack (most recent call first): /usr/local/lib/cmake/Boost-1.73.0/BoostConfig.cmake:258 (boost_find_component) /usr/local/share/cmake-3.17/Modules/FindBoost.cmake:444 (find_package) CMakeLists.txt:194 (find_package)
-- Configuring incomplete, errors occurred! See also "/usr/workspace/trojan-plus/gt5300_build/CMakeFiles/CMakeOutput.log".
You CANNOT use Android libs file for your router linux system compiling, although they both use arm CPU, for example, you cannot use Windows' exe file to run it in Linux system, they both use Intel x86 CPU.
Please DO find a way for compiling boost in your arm system firstly, download codes of boost: https://www.boost.org/users/download/
try to search on google for compiling boost in raspberry pi that uses arm CPU too.
You CANNOT use Android libs file for your router linux system compiling, although they both use arm CPU, for example, you cannot use Windows' exe file to run it in Linux system, they both use Intel x86 CPU.
Please DO find a way for compiling boost in your arm system firstly, download codes of boost: https://www.boost.org/users/download/
try to search on google for compiling boost in raspberry pi that uses arm CPU too.
I already have cross compiled the boost and openssl for my router system but how can I change the find_package() to use the them the cmake alway the /usr/local/lib/cmake/ But I want the cmake use the /usr/local/boost_arm/lib/cmake/
you can set a path for compiling:
cmake
-DOPENSSL_ROOT_DIR=/usr/local/include/openssl
-DOPENSSL_LIBRARIES=/usr/local/include/openssl/lib
-DBoost_INCLUDE_DIR=/usr/local/include/
-DBoost_LIBRARIES=/usr/local/include/boost/lib
..
or
cmake
-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
-DBoost_INCLUDE_DIR=/usr/local/include/
-DBoost_LIBRARIES=/usr/local/include/boost/lib
..
doesn't need to change CMakeLists.txt. Please check wiki for detail: https://github.com/Trojan-Plus-Group/trojan-plus/wiki/Compiling#set-explicit-includelibraries-paths-for-cmake
you can set a path for compiling:
cmake -DOPENSSL_ROOT_DIR=/usr/local/include/openssl -DOPENSSL_LIBRARIES=/usr/local/include/openssl/lib -DBoost_INCLUDE_DIR=/usr/local/include/ -DBoost_LIBRARIES=/usr/local/include/boost/lib ..
or
cmake -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 -DBoost_INCLUDE_DIR=/usr/local/include/ -DBoost_LIBRARIES=/usr/local/include/boost/lib ..
doesn't need to change CMakeLists.txt. Please check wiki for detail: https://github.com/Trojan-Plus-Group/trojan-plus/wiki/Compiling#set-explicit-includelibraries-paths-for-cmake
Thank you I have found a way to slove it I add a toolchain file cmake as following
cmake -DENABLE_MYSQL=OFF -DBoost_USE_STATIC_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=../Aarch64_Toolchain ..
Aarch64_Toolchain as following
# this is required
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# specify the cross compiler
set(CMAKE_CXX_COMPILER /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++)
set(CMAKE_C_COMPILER /usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc)
set(CMAKE_C_FLAGS_RELEASE -static)
set(CMAKE_CXX_FLAGS_RELEASE -static)
# where is the target environment
set(Boost_USE_STATIC_LIBS ON)
set(OPENSSL_INCLUDE_DIR /usr/local/openssl_aarch64/include)
set(OPENSSL_LIBRARIES /usr/local/openssl_aarch64/lib)
set(OPENSSL_CRYPTO_LIBRARY /usr/local/openssl_aarch64/lib/libcrypto.a)
set(OPENSSL_SSL_LIBRARY /usr/local/openssl_aarch64/lib/libssl.a)
set(Boost_DIR /usr/local/boost_aarch64/lib/cmake/Boost-1.73.0)
set(Boost_INCLUDE_DIR /usr/local/boost_aarch64/include)
set(Boost_LIBRARIES /usr/local/boost_aarch64/lib)
set(Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE /usr/local/boost_aarch64/lib/ibboost_program_options.a)
set(Boost_SYSTEM_LIBRARY_RELEASE /usr/local/boost_aarch64/lib/libboost_system.a)
set(boost_headers_DIR /usr/local/boost_aarch64/lib/cmake/boost_headers-1.73.0)
set(boost_program_options_DIR /usr/local/boost_aarch64/lib/cmake/boost_program_options-1.73.0)
set(boost_system_DIR /usr/local/boost_aarch64/lib/cmake/boost_system-1.73.0)
router need a static version, so I add -static in toolchain file
@MQSDREAM I'm glad to hear you have solved this problem :)
I have got some problems when I compiling trojan. I have followed all your compiling guides, except gcc version. My gcc version is 8.1.0. System and toolchain version as following root@SickProfuse-VM:~# cat /proc/version Linux version 4.14.129-bbrplus (root@vultr.guest) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 SMP Mon Jun 24 16:51:05 UTC 2019 root@SickProfuse-VM:~# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-8.1.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib Thread model: posix gcc version 8.1.0 (GCC) root@SickProfuse-VM:~# cmake --version cmake version 3.17.0
CMake suite maintained and supported by Kitware (kitware.com/cmake). root@SickProfuse-VM:~# openssl version OpenSSL 1.1.1g 21 Apr 2020
The information about the issue as following [100%] Linking CXX executable trojan /usr/bin/ld: /usr/local/lib/mariadb/libmysqlclient.a(ma_client_plugin.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/trojan.dir/build.make:945: recipe for target 'trojan' failed make[2]: [trojan] Error 1 CMakeFiles/Makefile2:92: recipe for target 'CMakeFiles/trojan.dir/all' failed make[1]: [CMakeFiles/trojan.dir/all] Error 2 Makefile:157: recipe for target 'all' failed make: *** [all] Error 2
And I add -ldl in CMakeLists.txt , but nothing happened.
And i add ${CMAKE_DL_LIBS} in target_link_libraries, the issue is different The information of the issue as following [100%] Linking CXX executable trojan 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 CMakeFiles/trojan.dir/build.make:948: recipe for target 'trojan' failed make[2]: [trojan] Error 1 CMakeFiles/Makefile2:92: recipe for target 'CMakeFiles/trojan.dir/all' failed make[1]: [CMakeFiles/trojan.dir/all] Error 2 Makefile:157: recipe for target 'all' failed make: *** [all] Error 2