I continued with the Gentoo ebuild approach, and got around most of the library dependencies problem. I will probably not continue with CMake way, because it is very gentoo-incompatibile.
However, now i get this while trying to compile code:
obj/bitcoinminercuda.o: In function `CUDARunner::RunStep()':
bitcoinminercuda.cpp:(.text+0x301): undefined reference to `cudaMemcpy'
bitcoinminercuda.cpp:(.text+0x332): undefined reference to `cuda_process_helper(cuda_in*, cuda_out*, unsigned int, unsigned int, int, int)'
bitcoinminercuda.cpp:(.text+0x351): undefined reference to `cudaMemcpy'
bitcoinminercuda.cpp:(.text+0x3e5): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x41c): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::AllocateResources(int, int)':
bitcoinminercuda.cpp:(.text+0x48c): undefined reference to `cudaMalloc'
bitcoinminercuda.cpp:(.text+0x49c): undefined reference to `cudaMalloc'
bitcoinminercuda.cpp:(.text+0x4d1): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x508): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::DeallocateResources()':
bitcoinminercuda.cpp:(.text+0x544): undefined reference to `cudaFree'
bitcoinminercuda.cpp:(.text+0x574): undefined reference to `cudaFree'
bitcoinminercuda.cpp:(.text+0x591): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x5c8): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::~CUDARunner()':
bitcoinminercuda.cpp:(.text+0x5f1): undefined reference to `cudaThreadExit'
bitcoinminercuda.cpp:(.text+0x60c): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::~CUDARunner()':
bitcoinminercuda.cpp:(.text+0x661): undefined reference to `cudaThreadExit'
bitcoinminercuda.cpp:(.text+0x675): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::~CUDARunner()':
bitcoinminercuda.cpp:(.text+0x6d1): undefined reference to `cudaThreadExit'
bitcoinminercuda.cpp:(.text+0x6e5): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::CUDARunner()':
bitcoinminercuda.cpp:(.text+0x76a): undefined reference to `cudaGetDeviceCount'
bitcoinminercuda.cpp:(.text+0x79c): undefined reference to `cudaSetDevice'
bitcoinminercuda.cpp:(.text+0x7c0): undefined reference to `cudaSetDevice'
bitcoinminercuda.cpp:(.text+0x7cb): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x7f8): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x82f): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::CUDARunner()':
bitcoinminercuda.cpp:(.text+0x88a): undefined reference to `cudaGetDeviceCount'
bitcoinminercuda.cpp:(.text+0x8bc): undefined reference to `cudaSetDevice'
bitcoinminercuda.cpp:(.text+0x8e0): undefined reference to `cudaSetDevice'
bitcoinminercuda.cpp:(.text+0x8eb): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x918): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0x94f): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `CUDARunner::FindBestConfiguration()':
bitcoinminercuda.cpp:(.text+0xa7b): undefined reference to `cudaGetLastError'
bitcoinminercuda.cpp:(.text+0xaab): undefined reference to `cudaMemcpy'
bitcoinminercuda.cpp:(.text+0xad0): undefined reference to `cuda_process_helper(cuda_in*, cuda_out*, unsigned int, unsigned int, int, int)'
bitcoinminercuda.cpp:(.text+0xae5): undefined reference to `cudaMemcpy'
bitcoinminercuda.cpp:(.text+0xaf2): undefined reference to `cudaGetLastError'
bitcoinminercuda.cpp:(.text+0xc1e): undefined reference to `cudaGetErrorString'
bitcoinminercuda.cpp:(.text+0xc55): undefined reference to `cudaGetErrorString'
obj/bitcoinminercuda.o: In function `cutGetMaxGflopsDeviceId()':
bitcoinminercuda.cpp:(.text._Z23cutGetMaxGflopsDeviceIdv[cutGetMaxGflopsDeviceId()]+0x46): undefined reference to `cudaGetDeviceCount'
bitcoinminercuda.cpp:(.text._Z23cutGetMaxGflopsDeviceIdv[cutGetMaxGflopsDeviceId()]+0x66): undefined reference to `cudaGetDeviceProperties'
bitcoinminercuda.cpp:(.text._Z23cutGetMaxGflopsDeviceIdv[cutGetMaxGflopsDeviceId()]+0xca): undefined reference to `cudaGetDeviceProperties'
collect2: ld returned 1 exit status
It seems I am missing some library or something.
Also, my libraries paths & include paths in the makefile are as follows:
INCLUDEPATHS= \
-I"/usr/include" \
-I"/usr/include/crypto++" \
-I"@@GENTOO_DB_INCLUDEDIR@@" \
-I"/opt/cuda/sdk/C/common/inc/" \
-I"/opt/cuda/include/"
LIBPATHS= \
-L"/usr/lib" \
-L"/opt/cuda/lib64" -lcufft -lcudart -Wl,-rpath,/opt/cuda/lib64
LIBS := ${LDFLAGS} -dead_strip \
-ldb_cxx -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lgthread-2.0 -lssl -lcrypto -lcrypto++ -lgmp -ldl -lz
Once again, I am not a C++ programmer (too bad).
EDIT:
To be clear, i have moved all of the *.cpp, *.h and *.cu files from the data/ & gpucommon/ directory, to the root directory to make it easier resolving dependencies.You may also find this part of the makefile useful:
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h bitcoinminercuda.h \
cudashared.h gpucommon.h
all: bitcoind
OBJS= \
obj/util.o \
obj/script.o \
obj/db.o \
obj/net.o \
obj/irc.o \
obj/main.o \
obj/rpc.o \
obj/init.o \
obj/bitcoinminercuda.o \
obj/gpucommon.o
# cryptopp/obj/sha.o
# cryptopp/obj/cpu.o
bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o
g++ $(CFLAGS) -o $@ $^ $(LIBPATHS) $(LIBS)
bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o
g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
#cryptopp/obj/%.o: cryptopp/%.cpp
# g++ -c $(CFLAGS) -O3 -o $@ $<
obj/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) $(WXDEFS) -DGUI -o $@ $<
obj/sha256.o: sha256.cpp
g++ -c $(CFLAGS) @@GENTOO_SHA256_SSE2@@ -o $@ $<
obj/nogui/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $<
I promise to make the Gentoo cuda ebuild public after i make this work.