chavezcoin-project / chavezcoinwallet

The ChavezCoin Wallet
GNU Lesser General Public License v3.0
1 stars 7 forks source link

compiling with windows platform #1

Open dinastyoffreedom opened 7 years ago

dinastyoffreedom commented 7 years ago

Hello I trying to compile the wallet sources with windows using Qt5 creator 5.5.1 and MSVC2013 64bit , the compilation it is ok 100%, but at the end there is a problem to link the library librockdsb.lib it cannot found. So I added manually this library generated from the main coin project and after that it was found, but the error message say that there are incompatibility issues with static library with dynamic library. I think the library should be create during compilation. I think should be add something within the ccmakelist so that this library should be generated and linked statically to the exe file. before that maybe I asking if Have you already solved this issue? for Unix I saw that there are instructions to create the library librockdb.a so probably everything is compiled correctly with unix (I will test it tomorrow) regards

freemanjackal commented 7 years ago

@loldlm1 did you manage to connect the wallet gui??, i have cmpiled without error and execute it fine, but i cant connect to another node, the cli version is able to connect easily bt i cant do the same with the gui, i am trying my own crypto by the way. is there anything that i am missing??

dinastyoffreedom commented 7 years ago

freemanjackal I compiled without error on linux, with Windows it compile too but cannot link rockdblib.lib ... have you compiled also in windows? or linux only. if you compiled with windows let me know if you changed something on cmakelist.txt. I try to compile using Qt5 Creator

dinastyoffreedom commented 7 years ago

freemanjackal at end I compiled too with windows using qt 5.9.1 using all static library.. and mscv'2013 I recompiled also at sources in static mode and libboost too. So all static library compile a 64 bit in debug mode... but when run there is a problem that is a windows bug, sincewhen build a string buffer memory within the exe it release the buffer using a Windows DLL external and this crash... I reading some other on internet forum with same problem. so the solution could be compile in Relase mode, since seem that in this way it work... But problem is that when compile in release qt static library cannot link since are at 32 bit. So trying to compile all stuff in 32 bit static. but still other problems... there should be also the option to compile all in Dynamic mode but I think other problem will born with Libbost or Qt or coin library so before continue I would like to ask you what you are used to compile.. wich visual studio version 2013 2015 or 2017 and if you are using QtCreator wich library of QT you are used 5.9.1 5.9.2 or older? Your answer will be appreciate thank

freemanjackal commented 7 years ago

i have handled to compiled it ok, full functioning, rigth now i dont have the code but is very simple, i dont have experience with c++ and cmake and it was tedious job thats why it took so long, for someone with experience that would be really easy, just minuts. as soon as i can i show you the way

freemanjackal commented 7 years ago

try this and let me know

cmake_minimum_required(VERSION 2.8)

include(CryptoNoteWallet.cmake)

project(${CN_PROJECT_NAME})

execute_process(COMMAND git log -1 --pretty=format:%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION)

#SET(CMAKE_C_FLAGS_DEBUG "/MTd /Z7 /Od")

set(CRYPTONOTE_LIB cryptonote)

include_directories(${CMAKE_BINARY_DIR}
    src
    include
    cryptonote/external
    cryptonote/external/rocksdb/include
    cryptonote/include
    cryptonote/src)

find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5DBus REQUIRED)

set(CMAKE_AUTOMOC ON)

add_subdirectory(${CMAKE_SOURCE_DIR}/cryptonote)
#${Qt5DBus_INCLUDE_DIRS} the first one
include_directories(${Qt5DBus_INCLUDE_DIRS} cryptonote/external/rocksdb/include/ include src external "${CMAKE_CURRENT_BINARY_DIR}/version")

#set(Boost_USE_STATIC_LIBS ON)
if(WIN32)
  set(Boost_USE_STATIC_RUNTIME OFF)
  set(Boost_USE_STATIC_LIBS ON)
else(WIN32)
  set(Boost_USE_STATIC_RUNTIME ON)
endif(WIN32)

find_package(Boost 1.58 REQUIRED COMPONENTS date_time filesystem program_options regex serialization system thread chrono)
if ((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54))
  message(SEND_ERROR "Boost version 1.58 is unsupported, more details are available here http://goo.gl/RrCFmA")
endif ()

include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

set(VERSION "")
configure_file("cryptonote/src/version.h.in" "version.h")
configure_file("src/CryptoNoteWalletConfig.h.in" "CryptoNoteWalletConfig.h")

add_definitions(-DGIT_REVISION="${GIT_REVISION}")

set(CMAKE_AUTOMOC ON)
#add_definitions(-DSTATICLIB)
file(GLOB_RECURSE CRYPTONOTE_SOURCES
  cryptonote/external/miniupnpc/connecthostport.c
  cryptonote/external/miniupnpc/igd_desc_parse.c
  cryptonote/external/miniupnpc/minisoap.c
  cryptonote/external/miniupnpc/miniupnpc.c
  cryptonote/external/miniupnpc/miniwget.c
  cryptonote/external/miniupnpc/minixml.c
  cryptonote/external/miniupnpc/portlistingparse.c
  cryptonote/external/miniupnpc/receivedata.c
  cryptonote/external/miniupnpc/upnpcommands.c
  cryptonote/external/miniupnpc/upnpreplyparse.c
  cryptonote/src/BlockchainExplorer/BlockchainExplorer.cpp
  cryptonote/src/BlockchainExplorer/BlockchainExplorerErrors.cpp
  cryptonote/src/Common/Base58.cpp
  cryptonote/src/Common/CommandLine.cpp
  cryptonote/src/Common/Util.cpp
  cryptonote/src/Common/StringTools.cpp
  cryptonote/src/Common/JsonValue.cpp
  cryptonote/src/Common/ConsoleTools.cpp
  cryptonote/src/Common/MemoryInputStream.cpp
  cryptonote/src/Common/PathTools.cpp
  cryptonote/src/Common/StdInputStream.cpp
  cryptonote/src/Common/StdOutputStream.cpp
  cryptonote/src/Common/StreamTools.cpp
  cryptonote/src/Common/StringOutputStream.cpp
  cryptonote/src/Common/StringView.cpp
  cryptonote/src/Common/VectorOutputStream.cpp
  cryptonote/src/Common/ScopeExit.cpp
  cryptonote/src/ConnectivityTool/ConnectivityTool.cpp
  cryptonote/src/crypto/blake256.c
  cryptonote/src/crypto/chacha8.c
  cryptonote/src/crypto/crypto-ops-data.c
  cryptonote/src/crypto/crypto-ops.c
  cryptonote/src/crypto/crypto.cpp
  cryptonote/src/crypto/groestl.c
  cryptonote/src/crypto/hash-extra-blake.c
  cryptonote/src/crypto/hash-extra-groestl.c
  cryptonote/src/crypto/hash-extra-jh.c
  cryptonote/src/crypto/hash-extra-skein.c
  cryptonote/src/crypto/hash.c
  cryptonote/src/crypto/jh.c
  cryptonote/src/crypto/keccak.c
  cryptonote/src/crypto/oaes_lib.c
  cryptonote/src/crypto/random.c
  cryptonote/src/crypto/skein.c
  cryptonote/src/crypto/slow-hash.c
  cryptonote/src/crypto/slow-hash.cpp
  cryptonote/src/crypto/tree-hash.c
  cryptonote/src/CryptoNoteCore/*.cpp
  cryptonote/src/CryptoNoteProtocol/*.cpp
  cryptonote/src/Daemon/*.cpp
  cryptonote/src/HTTP/*.cpp
  cryptonote/src/InProcessNode/InProcessNode.cpp
  cryptonote/src/InProcessNode/InProcessNodeErrors.cpp
  cryptonote/src/Logging/*.cpp
  cryptonote/src/NodeRpcProxy/NodeErrors.cpp
  cryptonote/src/NodeRpcProxy/NodeRpcProxy.cpp
  cryptonote/src/P2p/*.cpp
  cryptonote/src/Rpc/*.cpp
  cryptonote/src/Serialization/*.cpp
  cryptonote/src/Transfers/BlockchainSynchronizer.cpp
  cryptonote/src/Transfers/SynchronizationState.cpp
  cryptonote/src/Transfers/TransfersConsumer.cpp
  cryptonote/src/Transfers/TransfersContainer.cpp
  cryptonote/src/Transfers/TransfersSubscription.cpp
  cryptonote/src/Transfers/TransfersSynchronizer.cpp
  cryptonote/src/Wallet/*.cpp
  cryptonote/src/WalletLegacy/KeysStorage.cpp
  cryptonote/src/WalletLegacy/WalletLegacy.cpp
  cryptonote/src/WalletLegacy/WalletHelper.cpp
  cryptonote/src/WalletLegacy/WalletLegacySerializer.cpp
  cryptonote/src/WalletLegacy/WalletLegacySerialization.cpp
  cryptonote/src/WalletLegacy/WalletTransactionSender.cpp
  cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp
  cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp
  cryptonote/src/System/ContextGroup.cpp
  cryptonote/src/System/Event.cpp
  cryptonote/src/System/EventLock.cpp
  cryptonote/src/System/InterruptedException.cpp
  cryptonote/src/System/Ipv4Address.cpp
  cryptonote/src/System/TcpStream.cpp
  cryptonote/src/JsonRpcServer/*.cpp
  cryptonote/src/PaymentGate/*.cpp
  cryptonote/src/PaymentGateService/*.cpp
  cryptonote/src/Miner/*.cpp
)

file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.h)
file(GLOB_RECURSE FORMS src/gui/ui/*.ui)

if(MSVC)
  include_directories(Platform/Windows)
  set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/Windows/ApplicationEventHandler.cpp)
endif()

set(QRC src/resources.qrc)

qt5_wrap_ui(UIS ${FORMS})
qt5_add_resources(RCC ${QRC})

#set(CMAKE_CXX_FLAGS "-D_ALLOW_RUNTIME_LIBRARY_MISMATCH") 

if (WIN32)
  if (NOT MSVC)
    message(FATAL_ERROR "Only MSVC is supported on this platform")
  endif ()
  add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DSTATICLIB)
  include_directories(cryptonote/src/platform/msc)

  set(PLATFORM_DIR Windows)
  set(BUILD_PLATFORM WIN32)
  set(BUILD_RESOURCES src/chavezcoinwallet.rc)
  set(QTMAIN Qt5::WinMain)
endif ()

include_directories(cryptonote/src/Platform/${PLATFORM_DIR})
file(GLOB PLATFORM_SOURCES cryptonote/src/Platform/${PLATFORM_DIR}/System/*)
set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} ${PLATFORM_SOURCES} ${CRYPTONOTE_PLATFORM})

#took away static
#freeman

#set (CMAKE_STATIC_LINKER_FLAGS "-Wl,--as-needed")
#set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")

#${Qt5DBus_LIBRARIES} after boost
add_library(${CRYPTONOTE_LIB} STATIC ${CRYPTONOTE_SOURCES})
set_target_properties(${CRYPTONOTE_LIB} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(${CRYPTONOTE_LIB} ${Boost_LIBRARIES} ${Qt5DBus_LIBRARIES} rocksdblib ws2_32 Rpcrt4)

add_executable(${PROJECT_NAME} ${BUILD_PLATFORM} ${BUILD_RESOURCES} ${SOURCES} ${HEADERS} ${UIS} ${RCC})

#${Qt5DBus_LIBRARIES} after cryptonote lib
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${QTMAIN} ${CRYPTONOTE_LIB} ${Qt5DBus_LIBRARIES} rocksdblib ws2_32 Rpcrt4)

if (APPLE)
  qt5_use_modules(${PROJECT_NAME} PrintSupport)
elseif (UNIX)
  target_link_libraries(${PROJECT_NAME} -lpthread)
elseif (WIN32)
  target_link_libraries(${PROJECT_NAME} Imm32 Iphlpapi Winmm)
endif (APPLE)

qt5_use_modules(${PROJECT_NAME} Widgets Gui Network)
loldlm1 commented 7 years ago

Oh sorry guys, i there was not saw it, i was really busy with another forks, really appreciate your help.

With the actual CMakelist i could compile in ubuntu but it had an error syncing the blockchain and crash, if that CMake solve this would be awesome, thanks @freemanjackal.

freemanjackal commented 7 years ago

thats just for windows, because for linux it works the one from this repo... for linux you should change it, i did not even test it for it, it wont work