Browse Source

Fix cmake and linking

pool
Sammy Libre 8 years ago
parent
commit
61fe2a87f8
  1. 45
      README.md
  2. 28
      cnutil/CMakeLists.txt
  3. 13
      cnutil/cnutil.c
  4. 5
      cnutil/cnutil.go
  5. 12
      cnutil/cnutilxx/main.h
  6. 4
      cnutil/src/cnutil.cpp
  7. 10
      cnutil/src/cnutil.h
  8. 7
      hashing/CMakeLists.txt
  9. 2
      hashing/hashing.go

45
README.md

@ -8,55 +8,52 @@ High performance CryptoNote mining stratum written in Golang.
* AES-NI enabled share validation code with fallback to slow implementation * AES-NI enabled share validation code with fallback to slow implementation
* Integrated NewRelic performance monitoring plugin * Integrated NewRelic performance monitoring plugin
### Installation ## Installation
Dependencies: Dependencies:
* go-1.6 * go-1.6
* Everything required to build monero * Everything required to build monero
* Monero **v0.10.0** * Monero >= **v0.10.0**
#### Mac OS X ### Linux
Install required packages: Use Ubuntu 16.04 LTS.
brew update && brew install go Compile Monero source (with libraries option):
export GOPATH=~/go
go get github.com/yvasiyarov/gorelic
Download and compile [Monero](https://github.com/monero-project/monero) **v0.10.0**. cmake -DBUILD_SHARED_LIBS=1 .
make
Now clone stratum repo and compile it: Install Golang and packages:
git clone https://github.com/sammy007/go-cryptonote-pool.git sudo apt-get install golang
cmake . export GOPATH=~/go
make go get github.com/yvasiyarov/gorelic
Notice that for share validation stratum requires monero source tree where .a libs already compiled. By default stratum will use <code>../monero</code> directory. You can override this behavior by passing <code>MONERO_DIR</code> env variable: Build CGO extensions:
MONERO_DIR=/path/to/monero cmake . MONERO_DIR=/opt/src/monero cmake .
make make
Build stratum: Build stratum:
go build -o pool main.go go build -o pool main.go
#### Linux ### Mac OS X
I would recommend you to use Ubuntu 16.04 LTS. Install Golang and packages packages:
Install required packages: brew update && brew install go
sudo apt-get install golang
export GOPATH=~/go export GOPATH=~/go
go get github.com/yvasiyarov/gorelic go get github.com/yvasiyarov/gorelic
In order to successfully link with monero libs, recompile monero with: Compile Monero source:
cmake . cmake .
CXXFLAGS="-fPIC" CFLAGS="-fPIC" make make
Build CGO extensions: Now clone stratum repo and compile it:
MONERO_DIR=/opt/src/monero cmake . MONERO_DIR=/opt/src/monero cmake .
make make
@ -65,11 +62,11 @@ Build stratum:
go build -o pool main.go go build -o pool main.go
#### Running Stratum ### Running Stratum
./pool config.json ./pool config.json
### Configuration ## Configuration
Configuration is self-describing, just copy *config.example.json* to *config.json* and run stratum with path to config file as 1st argument. Configuration is self-describing, just copy *config.example.json* to *config.json* and run stratum with path to config file as 1st argument.

28
cnutil/CMakeLists.txt

@ -1,4 +1,4 @@
set(CXXLIB "cnutilxx") set(CXXLIB "cnutil")
find_package(Boost COMPONENTS thread system program_options date_time filesystem REQUIRED) find_package(Boost COMPONENTS thread system program_options date_time filesystem REQUIRED)
@ -9,14 +9,21 @@ include_directories(${Boost_INCLUDE_DIRS})
include_directories("${MONERO_DIR}/contrib/epee/include") include_directories("${MONERO_DIR}/contrib/epee/include")
include_directories("${MONERO_DIR}/src") include_directories("${MONERO_DIR}/src")
link_directories(
${MONERO_DIR}/src/cryptonote_core
${MONERO_DIR}/src/crypto
${MONERO_DIR}/src/common
${MONERO_DIR}/src/ringct
)
# Build library # Build library
add_library(${CXXLIB} SHARED cnutilxx/main.cpp) add_library(${CXXLIB} SHARED src/cnutil.cpp)
target_link_libraries(${CXXLIB} target_link_libraries(${CXXLIB}
${MONERO_DIR}/src/cryptonote_core/libcryptonote_core.a cryptonote_core
${MONERO_DIR}/src/crypto/libcrypto.a crypto
${MONERO_DIR}/src/common/libcommon.a common
${MONERO_DIR}/src/ringct/libringct.a ringct
) )
target_link_libraries(${CXXLIB} target_link_libraries(${CXXLIB}
@ -26,12 +33,3 @@ target_link_libraries(${CXXLIB}
${Boost_DATE_TIME_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}
) )
set(LIB "cnutil")
# Flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE")
# Build library
add_library(${LIB} SHARED cnutil.c)
target_link_libraries(${LIB} ${CXXLIB})

13
cnutil/cnutil.c

@ -1,13 +0,0 @@
#include <stdint.h>
#include "stdbool.h"
#include <stdio.h>
#include <stdlib.h>
#include "cnutilxx/main.h"
uint32_t convert_blob(const char *blob, size_t len, char *out) {
return cn_convert_blob(blob, len, out);
}
bool validate_address(const char *addr, size_t len) {
return cn_validate_address(addr, len);
}

5
cnutil/cnutil.go

@ -1,8 +1,9 @@
package cnutil package cnutil
// #cgo CFLAGS: -std=c11 -D_GNU_SOURCE // #cgo CFLAGS: -std=c11 -D_GNU_SOURCE
// #cgo LDFLAGS: -L${SRCDIR} -lcnutil -lcnutilxx -lstdc++ // #cgo LDFLAGS: -L${SRCDIR} -lcnutil -Wl,-rpath ${SRCDIR} -lstdc++
// #include "cnutil.h" // #include <stdlib.h>
// #include "src/cnutil.h"
import "C" import "C"
import "unsafe" import "unsafe"

12
cnutil/cnutilxx/main.h

@ -1,12 +0,0 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
uint32_t cn_convert_blob(const char *blob, uint32_t len, char *out);
bool cn_validate_address(const char *addr, uint32_t len);
#ifdef __cplusplus
}
#endif

4
cnutil/cnutilxx/main.cpp → cnutil/src/cnutil.cpp

@ -5,7 +5,7 @@
using namespace cryptonote; using namespace cryptonote;
extern "C" uint32_t cn_convert_blob(const char *blob, size_t len, char *out) { extern "C" uint32_t convert_blob(const char *blob, size_t len, char *out) {
std::string input = std::string(blob, len); std::string input = std::string(blob, len);
std::string output = ""; std::string output = "";
@ -19,7 +19,7 @@ extern "C" uint32_t cn_convert_blob(const char *blob, size_t len, char *out) {
return output.length(); return output.length();
} }
extern "C" bool cn_validate_address(const char *addr, size_t len) { extern "C" bool validate_address(const char *addr, size_t len) {
std::string input = std::string(addr, len); std::string input = std::string(addr, len);
std::string output = ""; std::string output = "";
uint64_t prefix; uint64_t prefix;

10
cnutil/cnutil.h → cnutil/src/cnutil.h

@ -1,7 +1,13 @@
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include "stdbool.h" #include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
uint32_t convert_blob(const char *blob, uint32_t len, char *out); uint32_t convert_blob(const char *blob, uint32_t len, char *out);
bool validate_address(const char *addr, uint32_t len); bool validate_address(const char *addr, uint32_t len);
#ifdef __cplusplus
}
#endif

7
hashing/CMakeLists.txt

@ -5,7 +5,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE")
include_directories("${MONERO_DIR}/contrib/epee/include") include_directories("${MONERO_DIR}/contrib/epee/include")
include_directories("${MONERO_DIR}/src") include_directories("${MONERO_DIR}/src")
link_directories(${MONERO_DIR}/src/crypto)
add_library(${LIB} SHARED src/hashing.c) add_library(${LIB} SHARED src/hashing.c)
target_link_libraries(${LIB}
${MONERO_DIR}/src/crypto/libcrypto.a target_link_libraries(${LIB} crypto)
)

2
hashing/hashing.go

@ -1,7 +1,7 @@
package hashing package hashing
// #cgo CFLAGS: -std=c11 -D_GNU_SOURCE // #cgo CFLAGS: -std=c11 -D_GNU_SOURCE
// #cgo LDFLAGS: -L${SRCDIR} -lhashing -lstdc++ // #cgo LDFLAGS: -L${SRCDIR} -lhashing -Wl,-rpath ${SRCDIR} -lstdc++
// #include <stdlib.h> // #include <stdlib.h>
// #include <stdint.h> // #include <stdint.h>
// #include "src/hashing.h" // #include "src/hashing.h"

Loading…
Cancel
Save