Skip to content

Commit

Permalink
Android and Mac OS build fixes
Browse files Browse the repository at this point in the history
Android build manual
Disable buffering for simplewallet
  • Loading branch information
aivve committed Jan 9, 2018
1 parent d4778e0 commit 44e6d13
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 24 deletions.
30 changes: 22 additions & 8 deletions CMakeLists.txt
Expand Up @@ -154,6 +154,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Windows)
elseif(APPLE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/OSX)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Posix)
elseif(ANDROID)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Android)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Posix)
else()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Linux)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Platform/Posix)
Expand Down Expand Up @@ -206,12 +209,12 @@ add_subdirectory(external)

# Final setup for miniupnpc
if(STATIC OR IOS)
# if(UPNP_STATIC OR IOS)
#if(UPNP_STATIC OR IOS)
add_definitions("-DUPNP_STATIC")
else()
else()
add_definitions("-DUPNP_DYNAMIC")
include_directories(${UPNP_INCLUDE})
endif()
endif()

if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /D__SSE4_1__")
Expand Down Expand Up @@ -240,7 +243,7 @@ else()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
# maybe remove
set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function")
set(WARNINGS "${WARNINGS} -Wno-unused-lambda-capture -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function")
# this ^
if(ARM)
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
Expand Down Expand Up @@ -397,8 +400,8 @@ else()
#From Android 5: "only position independent executables (PIE) are supported"
message(STATUS "Enabling PIE executable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -DANDROID -DBOOST_COROUTINES_NO_DEPRECATION_WARNING")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie -ldl -pthread")
endif()

if(APPLE)
Expand Down Expand Up @@ -474,7 +477,7 @@ if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
find_package(Boost 1.57 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options coroutine context) #context
find_package(Boost 1.57 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options coroutine context atomic)

set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND)
Expand All @@ -483,6 +486,14 @@ elseif(Boost_FOUND)
message(STATUS "Found Boost Version: ${Boost_VERSION}")
endif()

if(MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock;iphlpapi")
elseif(APPLE OR OPENBSD OR ANDROID)
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif(NOT MSVC)
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
endif()

include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi)
Expand All @@ -501,11 +512,14 @@ endif()
list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})

if(ANDROID)
set(ATOMIC libatomic.a)
set(ATOMIC /opt/android/boost_1_65_1/android32/lib/libboost_atomic.a)
set(THREAD /opt/android/boost_1_65_1/android32/lib/libboost_thread.a)
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS)
find_library(ATOMIC atomic)
find_library(THREAD thread)
list(APPEND EXTRA_LIBRARIES ${ATOMIC})
list(APPEND EXTRA_LIBRARIES ${THREAD})
endif()

include("${CMAKE_CURRENT_SOURCE_DIR}/src/version.cmake")
Expand Down
33 changes: 32 additions & 1 deletion README.md
@@ -1,4 +1,4 @@
The karbowanec is Ukrainian national cryptocurrency, just like Bitcoin but more anonymous and privacy centric with opaque and more analysis resistant blockchain. It is people's electronic cash, not connected to government or officials.
The Karbo (Karbovanets) is cryptocurrency of Ukrainian origin, just like Bitcoin but more anonymous and privacy centric with opaque and more analysis resistant blockchain. It is people's electronic cash, not connected to government or officials.

## Building Karbo

Expand Down Expand Up @@ -38,3 +38,34 @@ cmake -G "Visual Studio 12 Win64" ..

And then do Build.
Good luck!

### Building for Android on Linux

Set up the 32 bit toolchain
Download and extract the Android SDK and NDK
```
android-ndk-r15c/build/tools/make_standalone_toolchain.py --api 21 --stl=libc++ --arch arm --install-dir /opt/android/tool32
```

Download and setup the Boost 1.65.1 source
```
wget https://sourceforge.net/projects/boost/files/boost/1.65.1/boost_1_65_1.tar.bz2/download -O boost_1_65_1.tar.bz2
tar xjf boost_1_65_1.tar.bz2
cd boost_1_65_1
./bootstrap.sh
```
apply patch from external/boost1_65_1/libs/filesystem/src

Build Boost with the 32 bit toolchain
```
export PATH=/opt/android/tool32/arm-linux-androideabi/bin:/opt/android/tool32/bin:$PATH
./b2 abi=aapcs architecture=arm binary-format=elf address-model=32 link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --with-context --with-coroutine --with-atomic --build-dir=android32 --stagedir=android32 toolset=clang threading=multi threadapi=pthread target-os=android --reconfigure stage
```

Build Karbo for 32 bit Android
```
mkdir -p build/release.android32
cd build/release.android32
CC=clang CXX=clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -ldl -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D BUILD_TAG="android" -D BOOST_ROOT=/opt/android/boost_1_65_1 -D BOOST_LIBRARYDIR=/opt/android/boost_1_65_1/android32/lib -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -D BOOST_IGNORE_SYSTEM_PATHS_DEFAULT=ON ../..
make SimpleWallet
```
6 changes: 3 additions & 3 deletions include/android.h
Expand Up @@ -20,7 +20,7 @@ string to_string(T value)
return os.str();
}


/*
inline unsigned long stoul (std::string const& str, size_t *idx = 0, int base = 10)
{
char *endp;
Expand All @@ -36,6 +36,6 @@ inline unsigned long stoul (std::string const& str, size_t *idx = 0, int base =
return value;
}

*/
}// namespace std
#endif
#endif
14 changes: 8 additions & 6 deletions src/CMakeLists.txt
Expand Up @@ -20,6 +20,8 @@ if(MSVC)
file(GLOB_RECURSE System System/* Platform/Windows/System/*)
elseif(APPLE)
file(GLOB_RECURSE System System/* Platform/OSX/System/* Platform/Posix/System/*)
elseif(ANDROID)
file(GLOB_RECURSE System System/* Platform/Android/System/* Platform/Posix/System/*)
else()
file(GLOB_RECURSE System System/* Platform/Linux/System/* Platform/Posix/System/*)
endif()
Expand Down Expand Up @@ -63,13 +65,13 @@ if (MSVC)
target_link_libraries(System ws2_32)
endif ()

target_link_libraries(ConnectivityTool CryptoNoteCore Logging Crypto P2P Rpc Http Serialization Common System ${Boost_LIBRARIES})
target_link_libraries(Daemon CryptoNoteCore P2P Rpc System Http Logging Common Crypto upnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization)
target_link_libraries(SimpleWallet Wallet NodeRpcProxy Transfers Rpc Http CryptoNoteCore System Logging Common Crypto ${Boost_LIBRARIES} Serialization Mnemonics)
target_link_libraries(PaymentGateService PaymentGate JsonRpcServer Wallet NodeRpcProxy Transfers CryptoNoteCore Crypto P2P Rpc Http System Logging Common InProcessNode upnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization)
target_link_libraries(Miner CryptoNoteCore Rpc System Http Logging Common Crypto ${Boost_LIBRARIES} Serialization)
target_link_libraries(ConnectivityTool CryptoNoteCore Logging Crypto P2P Rpc Http Serialization Common System ${Boost_LIBRARIES} ${EXTRA_LIBRARIES})
target_link_libraries(Daemon CryptoNoteCore P2P Rpc System Http Logging Common Crypto upnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization ${EXTRA_LIBRARIES})
target_link_libraries(SimpleWallet Wallet NodeRpcProxy Transfers Rpc Http CryptoNoteCore System Logging Common Crypto ${Boost_LIBRARIES} Serialization Mnemonics ${EXTRA_LIBRARIES})
target_link_libraries(PaymentGateService PaymentGate JsonRpcServer Wallet NodeRpcProxy Transfers CryptoNoteCore Crypto P2P Rpc Http System Logging Common InProcessNode upnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization ${EXTRA_LIBRARIES})
target_link_libraries(Miner CryptoNoteCore Rpc System Http Logging Common Crypto ${Boost_LIBRARIES} Serialization ${EXTRA_LIBRARIES})

if (UNIX)
if (LINUX)

target_link_libraries(SimpleWallet -lresolv)

Expand Down
2 changes: 1 addition & 1 deletion src/Logging/LoggerMessage.cpp
Expand Up @@ -36,7 +36,7 @@ LoggerMessage::~LoggerMessage() {
}
}

#ifndef __linux__
#if defined(__ANDROID__) || defined(__APPLE__) || defined(WIN32)
LoggerMessage::LoggerMessage(LoggerMessage&& other)
: std::ostream(std::move(other))
, std::streambuf(std::move(other))
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/OSX/System/Context.c
Expand Up @@ -16,7 +16,7 @@
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.

#include <string.h>
#include "context.h"
#include "Context.h"

void
makecontext(uctx *ucp, void (*func)(void), intptr_t arg)
Expand Down
2 changes: 2 additions & 0 deletions src/SimpleWallet/SimpleWallet.cpp
Expand Up @@ -1898,6 +1898,8 @@ int main(int argc, char* argv[]) {
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

setbuf(stdout, NULL);

po::options_description desc_general("General options");
command_line::add_arg(desc_general, command_line::arg_help);
command_line::add_arg(desc_general, command_line::arg_version);
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/slow-hash.c
Expand Up @@ -33,7 +33,7 @@
#include <stdint.h>
#include <string.h>

#include "common/int-util.h"
#include "Common/int-util.h"
#include "hash-ops.h"
#include "oaes_lib.h"
#include "aesb.h"
Expand Down
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Expand Up @@ -37,7 +37,7 @@ add_executable(HashTargetTests HashTarget.cpp)
add_executable(HashTests Hash/main.cpp)

target_link_libraries(CoreTests TestGenerator CryptoNoteCore Serialization System Logging Common Crypto BlockchainExplorer ${Boost_LIBRARIES})
target_link_libraries(IntegrationTests IntegrationTestLibrary Wallet NodeRpcProxy InProcessNode P2P Rpc Http Transfers Serialization System CryptoNoteCore Logging Common Crypto BlockchainExplorer gtest upnpc-static ${Boost_LIBRARIES})
target_link_libraries(IntegrationTests IntegrationTestLibrary Wallet NodeRpcProxy InProcessNode P2P Rpc Http Transfers Serialization System CryptoNoteCore Logging Common Crypto BlockchainExplorer gtest Mnemonics upnpc-static ${Boost_LIBRARIES})
target_link_libraries(NodeRpcProxyTests NodeRpcProxy CryptoNoteCore Rpc Http Serialization System Logging Common Crypto ${Boost_LIBRARIES})
target_link_libraries(PerformanceTests CryptoNoteCore Serialization Logging Common Crypto ${Boost_LIBRARIES})
target_link_libraries(SystemTests System gtest_main)
Expand All @@ -47,8 +47,8 @@ if (MSVC)
target_link_libraries(CoreTests ws2_32)
endif ()

target_link_libraries(TransfersTests IntegrationTestLibrary Wallet gtest_main InProcessNode NodeRpcProxy P2P Rpc Http BlockchainExplorer CryptoNoteCore Serialization System Logging Transfers Common Crypto upnpc-static ${Boost_LIBRARIES})
target_link_libraries(UnitTests gtest_main PaymentGate Wallet TestGenerator InProcessNode NodeRpcProxy Rpc Http Transfers Serialization System Logging BlockchainExplorer CryptoNoteCore Common Crypto ${Boost_LIBRARIES})
target_link_libraries(TransfersTests IntegrationTestLibrary Wallet gtest_main InProcessNode NodeRpcProxy P2P Rpc Http BlockchainExplorer CryptoNoteCore Serialization System Logging Transfers Common Crypto Mnemonics upnpc-static ${Boost_LIBRARIES})
target_link_libraries(UnitTests gtest_main PaymentGate Wallet TestGenerator InProcessNode NodeRpcProxy Rpc Http Transfers Serialization System Logging BlockchainExplorer CryptoNoteCore Common Crypto Mnemonics ${Boost_LIBRARIES})

target_link_libraries(DifficultyTests CryptoNoteCore Serialization Crypto Logging Common ${Boost_LIBRARIES})
target_link_libraries(HashTargetTests CryptoNoteCore Crypto)
Expand Down
23 changes: 23 additions & 0 deletions utils/test-static-assert.c
@@ -0,0 +1,23 @@
// Copyright (c) 2012-2014, The CryptoNote developers, The Bytecoin developers
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.

#include <assert.h>

static_assert(1, "FAIL");
int main(int argc, char *argv[]) {
return 0;
}

0 comments on commit 44e6d13

Please sign in to comment.