And if I added #include "pow.cpp" at the top of chainparams.cpp, and wrote like
You want to include "pow.h" and only, not "pow.cpp"
undefined reference to `CheckProofOfWork
Why? how to use this function in chainparams.cpp?
Something like the following will work (Tested against last bitcoin version, commit bf3353de9059):
// In src/chainparams.cpp, in headers
#include
...
// still in src/chainparams.cpp, in CMainParams:CMainParams() (~ line #76)
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
uint32_t nNonce;
for(nNonce = 0; ; nNonce++){
genesis.nNonce = nNonce;
// You can also update genesis.nTime
if (CheckProofOfWork(genesis.GetHash(), genesis.nBits, consensus)) {
printf("hash: %s\n", genesis.GetHash().GetHex().c_str());
printf("nonce: %i\n", nNonce);
break;
}
if (nNonce == 0) {
printf("Can't find a valid nNonce.\n");
break;
}
}
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
Thanks, but still following errors.
---------------
lee@newlite:~/Desktop/BitcoinEssence/src$ make
make[1]: Entering directory '/home/lee/Desktop/BitcoinEssence/src'
make[2]: Entering directory '/home/lee/Desktop/BitcoinEssence'
make[2]: Leaving directory '/home/lee/Desktop/BitcoinEssence'
CXX libbitcoin_common_a-chainparams.o
AR libbitcoin_common.a
CXXLD bitcoinessenced
CXXLD bitcoinessence-tx
libbitcoin_common.a(libbitcoin_common_a-chainparams.o): In function `CMainParams::CMainParams()':
/home/lee/Desktop/BitcoinEssence/src/chainparams.cpp:262: undefined reference to `CheckProofOfWork(uint256, unsigned int, Consensus::Params const&)'
collect2: error: ld returned 1 exit status
Makefile:3663: recipe for target 'bitcoinessence-tx' failed
make[1]: *** [bitcoinessence-tx] Error 1
make[1]: Leaving directory '/home/lee/Desktop/BitcoinEssence/src'
Makefile:9337: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
lee@newlite:~/Desktop/BitcoinEssence/src$
---------------
Of course I added #include "pow.h" or