mysql – Is it true or just a myth that executing SQL Codes in the Database is the fastest in the entire web based application?

My Manager, who has been a DBA for like 20 years, told me that I should make maximum use of a database , because it is the fastest component in a web server. So, if I am using FrontEnd, PHP (Frameworks) and MySQL,

  • if I were to write a select statement, I should use stored procedure, where the Select statement is written, rather than writing raw Select queries in PHP

  • instead of joining two tables using join query in PHP, I should create a view using create view, where the required tables are joined, and then show the required data from this view.

  • if I need to add data to a different table after inserting or updating the main table, I should use a trigger rather than using a different select statement in the Stored Procedure.

Are these just myths ? If not, then why are databases the fastest, and how does using database queries in the database, faster than that using PHP?

Is a good practice reuse HTTP codes to encode something else?

As we know HTTP codes are used in HTTP response. Usually with this code we can have an idea about what happened. For example if I make a get request and I obtain a 404 I can figure out that the resource that I requested doesn’t exist on the server side.

Suppose that I want to encode the status of an object in the DB. For example let’s say that if the object exist but some data are missing (a specific field for example) I want to save it in my DB but express the status of the object with a column. This need to be an integer (suppose it is a constraint). I would go for 206 (partial content in HTTP).

From a code point of view suppose we have an enum to express the various possible status as this one:

public enum ValidationStatus {

    OK(HttpStatus.OK.value()),
    PARTIAL(HttpStatus.PARTIAL_CONTENT.value()),
    ...

    private final Integer code;
    ...

When someone reads the code, it seems that HTTP is involved in some way. But in this case it’s not. I’m reusing the HTTP status to represent something else.

I saw that in a project but I’m not sure about if this is a good practise. It’s like mixing things for me. I’m using something created for HTTP to represent something else.

Do you think that it is acceptable?

EDIT: to be more precise my was just an example of reusing HTTP code in other context. Actually in the DB is stored the string value (in this case PARTIAL) but in this microservices application, the services communicate with messages and in these messages you find the integer. When for example an object is in the status PARTIAL a notification is send to another service as if it is a sort of error. This question arose when I was running some tests, and in the log I so this: “ERROR 206 PARTIAL”. I saw this and the HTTP 206 status came into my mind. After that I discovered the use of this code in the application and so the enum class. My initial confusion brought me to ask this question. The I discovered that HTTP was not involved at all.

What is the intution behind working of hamming codes

I am trying to understand hamming codes for single bit error correction. I understood all the things like hamming distance , k bit error detection and all basics for hamming codes. Also, I know the algorithm for error correction using hamming codes. I have read many answers from different stackexchange sites and also I fear that this question may be marked as duplicated. But I am not satisfied, I just know a procedure and don’t know the intuition behind the idea.

Let’s say we need to send a 4-bit message for which three parity bits will be used. Now the sequence will be p1 p2 m3 p4 m5 m6 m7 and my instructor is saying that p1 will be responsible for ( 1 , 3 , 5 , 7 ) , p2 will be responsible for ( 2 , 3 , 6 , 7 ) and p4 will be responsible for ( 4 , 5 , 6 , 7 ). Why is it so?

Why only $2^n$ position bits are selected for parity? How to visualize its working?

bitcoin core development – so many “undefined reference to” after I add some codes, how to solve it?

I am just want to modify the hash algorithm of bitcoin-0.20 and I want to replace the previous hash algorithm to the x13hash algorithm. So I modify the source below,

1, I add the x13hash files to the bitcoin-0.20/src/crypto/x13hash, there are files below:

aes_helper.c  bmw.c       echo.c   groestl.c  hamsi_helper.c  keccak.c  shavite.c  skein.c  sph_blake.h  sph_cubehash.h  sph_fugue.h    sph_hamsi.h  sph_keccak.h  sph_shavite.h  sph_skein.h  sph_types.h
blake.c       cubehash.c  fugue.c  hamsi.c    jh.c            luffa.c   simd.c     sm3.c    sph_bmw.h    sph_echo.h      sph_groestl.h  sph_jh.h     sph_luffa.h   sph_simd.h     sph_sm3.h

2, I add a new function in block.h below

class CBlockHeader
{
public:
    // header
    int32_t nVersion;
    uint256 hashPrevBlock;
    uint256 hashMerkleRoot;
    uint32_t nTime;
    uint32_t nBits;
    uint32_t nNonce;

    CBlockHeader()
    {
        SetNull();
    }

    ADD_SERIALIZE_METHODS;

    template <typename Stream, typename Operation>
    inline void SerializationOp(Stream& s, Operation ser_action) {
        READWRITE(this->nVersion);
        READWRITE(hashPrevBlock);
        READWRITE(hashMerkleRoot);
        READWRITE(nTime);
        READWRITE(nBits);
        READWRITE(nNonce);
    }

    void SetNull()
    {
        nVersion = 0;
        hashPrevBlock.SetNull();
        hashMerkleRoot.SetNull();
        nTime = 0;
        nBits = 0;
        nNonce = 0;
    }

    bool IsNull() const
    {
        return (nBits == 0);
    }

    uint256 GetHash() const;
    uint256 GetNewPoWHash() const; //new hash function

    int64_t GetBlockTime() const
    {
        return (int64_t)nTime;
    }
};

3, add the function in block.cpp

#include <hash.h>
#include <tinyformat.h>

#define BEGIN(a)            ((char*)&(a))
#define END(a)              ((char*)&((&(a))(1)))
#define UBEGIN(a)           ((unsigned char*)&(a))
#define UEND(a)             ((unsigned char*)&((&(a))(1)))
#define ARRAYLEN(array)     (sizeof(array)/sizeof((array)(0)))

uint256 CBlockHeader::GetHash() const
{
    return SerializeHash(*this);
}
uint256 CBlockHeader::GetNewPoWHash() const //new !! 
{   
    return HashX13sm3(BEGIN(nVersion), END(nNonce));
}
  1. modify the hash.h below:

     #include <vector>
     // added new
     #include "crypto/x13hash/sph_blake.h"
     #include "crypto/x13hash/sph_bmw.h"
     #include "crypto/x13hash/sph_groestl.h"
     #include "crypto/x13hash/sph_jh.h"
     #include "crypto/x13hash/sph_keccak.h"
     #include "crypto/x13hash/sph_skein.h"
     #include "crypto/x13hash/sph_luffa.h"
     #include "crypto/x13hash/sph_cubehash.h"
     #include "crypto/x13hash/sph_shavite.h"
     #include "crypto/x13hash/sph_simd.h"
     #include "crypto/x13hash/sph_echo.h"
     #include "crypto/x13hash/sph_hamsi.h"
     #include "crypto/x13hash/sph_fugue.h"
     #include "crypto/x13hash/sph_sm3.h"
    
     #ifdef GLOBALDEFINED
     #define GLOBAL
     #else
     #define GLOBAL extern
     #endif
    
     GLOBAL sph_blake512_context     z_blake;
     GLOBAL sph_bmw512_context       z_bmw;
     GLOBAL sph_groestl512_context   z_groestl;
     GLOBAL sph_jh512_context        z_jh;
     GLOBAL sph_keccak512_context    z_keccak;
     GLOBAL sph_skein512_context     z_skein;
     GLOBAL sph_luffa512_context     z_luffa;
     GLOBAL sph_cubehash512_context  z_cubehash;
     GLOBAL sph_shavite512_context   z_shavite;
     GLOBAL sph_simd512_context      z_simd;
     GLOBAL sph_echo512_context      z_echo;
     GLOBAL sph_hamsi512_context     z_hamsi;
     GLOBAL sph_fugue512_context     z_fugue;
     #define fillz() do { 
         sph_blake512_init(&z_blake); 
         sph_bmw512_init(&z_bmw); 
         sph_groestl512_init(&z_groestl); 
         sph_jh512_init(&z_jh); 
         sph_keccak512_init(&z_keccak); 
         sph_skein512_init(&z_skein); 
         sph_luffa512_init(&z_luffa); 
         sph_cubehash512_init(&z_cubehash); 
         sph_shavite512_init(&z_shavite); 
         sph_simd512_init(&z_simd); 
         sph_echo512_init(&z_echo); 
         sph_hamsi512_init(&z_hamsi); 
         sph_fugue512_init(&z_fugue); 
     } while (0) 
     typedef uint256 ChainCode;
     template<typename T1>
    

    inline uint256 HashX13(const T1 pbegin, const T1 pend)

    {
    sph_blake512_context ctx_blake;
    sph_bmw512_context ctx_bmw;
    sph_groestl512_context ctx_groestl;
    sph_jh512_context ctx_jh;
    sph_keccak512_context ctx_keccak;
    sph_skein512_context ctx_skein;
    sph_luffa512_context ctx_luffa;
    sph_cubehash512_context ctx_cubehash;
    sph_shavite512_context ctx_shavite;
    sph_simd512_context ctx_simd;
    sph_echo512_context ctx_echo;
    sph_hamsi512_context ctx_hamsi;
    sph_fugue512_context ctx_fugue;
    static unsigned char pblank(1);

    #ifndef QT_NO_DEBUG
    //std::string strhash;
    //strhash = “”;
    #endif

     uint256 hash(34);
    
     sph_blake512_init(&ctx_blake);
     sph_blake512 (&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin(0))), (pend - pbegin) * sizeof(pbegin(0)));
     sph_blake512_close(&ctx_blake, static_cast<void*>(&hash(0)));
    
     sph_bmw512_init(&ctx_bmw);
     sph_bmw512 (&ctx_bmw, static_cast<const void*>(&hash(0)), 64);
     sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash(2)));
    
     sph_groestl512_init(&ctx_groestl);
     sph_groestl512 (&ctx_groestl, static_cast<const void*>(&hash(2)), 64);
     sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash(4)));
    
     sph_skein512_init(&ctx_skein);
     sph_skein512 (&ctx_skein, static_cast<const void*>(&hash(4)), 64);
     sph_skein512_close(&ctx_skein, static_cast<void*>(&hash(6)));
    
     sph_jh512_init(&ctx_jh);
     sph_jh512 (&ctx_jh, static_cast<const void*>(&hash(6)), 64);
     sph_jh512_close(&ctx_jh, static_cast<void*>(&hash(8)));
    
     sph_keccak512_init(&ctx_keccak);
     sph_keccak512 (&ctx_keccak, static_cast<const void*>(&hash(8)), 64);
     sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash(10)));
    
     sph_luffa512_init(&ctx_luffa);
     sph_luffa512 (&ctx_luffa, static_cast<void*>(&hash(10)), 64);
     sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash(12)));
    
     sph_cubehash512_init(&ctx_cubehash);
     sph_cubehash512 (&ctx_cubehash, static_cast<const void*>(&hash(12)), 64);
     sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash(14)));
    
     sph_shavite512_init(&ctx_shavite);
     sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash(14)), 64);
     sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash(16)));
    
     sph_simd512_init(&ctx_simd);
     sph_simd512 (&ctx_simd, static_cast<const void*>(&hash(16)), 64);
     sph_simd512_close(&ctx_simd, static_cast<void*>(&hash(18)));
    
     sph_echo512_init(&ctx_echo);
     sph_echo512 (&ctx_echo, static_cast<const void*>(&hash(18)), 64);
     sph_echo512_close(&ctx_echo, static_cast<void*>(&hash(20)));
    
     sph_hamsi512_init(&ctx_hamsi);
     sph_hamsi512 (&ctx_hamsi, static_cast<const void*>(&hash(20)), 64);
     sph_hamsi512_close(&ctx_hamsi, static_cast<void*>(&hash(22)));
    
     sph_fugue512_init(&ctx_fugue);
     sph_fugue512 (&ctx_fugue, static_cast<const void*>(&hash(22)), 64);
     sph_fugue512_close(&ctx_fugue, static_cast<void*>(&hash(24)));
    
    
     return hash(24);
    

    }

template
inline uint256 HashX13sm3(const T1 pbegin, const T1 pend)
{
sph_blake512_context ctx_blake;
sph_bmw512_context ctx_bmw;
sph_groestl512_context ctx_groestl;
sph_jh512_context ctx_jh;
sph_keccak512_context ctx_keccak;
sph_skein512_context ctx_skein;
sm3_ctx_t ctx_sm3;
sph_cubehash512_context ctx_cubehash;
sph_shavite512_context ctx_shavite;
sph_simd512_context ctx_simd;
sph_echo512_context ctx_echo;
sph_hamsi512_context ctx_hamsi;
sph_fugue512_context ctx_fugue;
static unsigned char pblank(1);

#ifndef QT_NO_DEBUG
//std::string strhash;
//strhash = “”;
#endif

uint256 hash(34);

sph_blake512_init(&ctx_blake);
sph_blake512 (&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin(0))), (pend - pbegin) * sizeof(pbegin(0)));
sph_blake512_close(&ctx_blake, static_cast<void*>(&hash(0)));

sph_bmw512_init(&ctx_bmw);
sph_bmw512 (&ctx_bmw, static_cast<const void*>(&hash(0)), 64);
sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash(2)));

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl, static_cast<const void*>(&hash(2)), 64);
    sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash(4)));

    sph_skein512_init(&ctx_skein);
    sph_skein512 (&ctx_skein, static_cast<const void*>(&hash(4)), 64);
    sph_skein512_close(&ctx_skein, static_cast<void*>(&hash(6)));

    sph_jh512_init(&ctx_jh);
    sph_jh512 (&ctx_jh, static_cast<const void*>(&hash(6)), 64);
    sph_jh512_close(&ctx_jh, static_cast<void*>(&hash(8)));

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, static_cast<const void*>(&hash(8)), 64);
    sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash(10)));

    hash(12).SetNull(); //sm3 is 256bit, just in case
    hash(13).SetNull();
    sm3_init(&ctx_sm3);
    sph_sm3(&ctx_sm3, static_cast<const void*>(&hash(10)), 64);
    sph_sm3_close(&ctx_sm3, static_cast<void*>(&hash(12)));

    sph_cubehash512_init(&ctx_cubehash);
    sph_cubehash512 (&ctx_cubehash, static_cast<const void*>(&hash(12)), 64);
    sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash(14)));

    sph_shavite512_init(&ctx_shavite);
    sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash(14)), 64);
    sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash(16)));

    sph_simd512_init(&ctx_simd);
    sph_simd512 (&ctx_simd, static_cast<const void*>(&hash(16)), 64);
    sph_simd512_close(&ctx_simd, static_cast<void*>(&hash(18)));

    sph_echo512_init(&ctx_echo);
    sph_echo512 (&ctx_echo, static_cast<const void*>(&hash(18)), 64);
    sph_echo512_close(&ctx_echo, static_cast<void*>(&hash(20)));

    sph_hamsi512_init(&ctx_hamsi);
    sph_hamsi512 (&ctx_hamsi, static_cast<const void*>(&hash(20)), 64);
    sph_hamsi512_close(&ctx_hamsi, static_cast<void*>(&hash(22)));

    sph_fugue512_init(&ctx_fugue);
    sph_fugue512 (&ctx_fugue, static_cast<const void*>(&hash(22)), 64);
    sph_fugue512_close(&ctx_fugue, static_cast<void*>(&hash(24)));


    return hash(24);
} /* added new above */
typedef uint256 ChainCode;  

Finally then I make again ,it shows error below:

CXX      script/libbitcoin_common_a-descriptor.o
  CXX      script/libbitcoin_common_a-sign.o
  CXX      script/libbitcoin_common_a-signingprovider.o
  CXX      script/libbitcoin_common_a-standard.o
  AR       libbitcoin_util.a
  AR       libbitcoin_consensus.a
  AR       libbitcoin_wallet_tool.a
  AR       libtest_util.a
  CXXLD    libbitcoinconsensus.la
  AR       libbitcoin_server.a
  AR       libbitcoin_wallet.a
  AR       libbitcoin_common.a
  CXXLD    bitcoin-cli
  CXXLD    bitcoin-tx
  CXXLD    bitcoin-wallet
  CXXLD    bitcoind
  CXXLD    test/test_bitcoin
/usr/bin/ld: libbitcoin_consensus.a(libbitcoin_consensus_a-block.o): in function `uint256 HashX13sm3<char*>(char*, char*)':
/home/gilsun91/bitcoin-0.20/src/./hash.h:178: undefined reference to `sph_blake512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:179: undefined reference to `sph_blake512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:180: undefined reference to `sph_blake512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:182: undefined reference to `sph_bmw512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:183: undefined reference to `sph_bmw512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:184: undefined reference to `sph_bmw512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:186: undefined reference to `sph_groestl512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:187: undefined reference to `sph_groestl512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:188: undefined reference to `sph_groestl512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:190: undefined reference to `sph_skein512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:191: undefined reference to `sph_skein512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:192: undefined reference to `sph_skein512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:194: undefined reference to `sph_jh512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:195: undefined reference to `sph_jh512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:196: undefined reference to `sph_jh512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:198: undefined reference to `sph_keccak512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:199: undefined reference to `sph_keccak512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:200: undefined reference to `sph_keccak512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:204: undefined reference to `sm3_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:205: undefined reference to `sph_sm3'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:206: undefined reference to `sph_sm3_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:208: undefined reference to `sph_cubehash512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:209: undefined reference to `sph_cubehash512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:210: undefined reference to `sph_cubehash512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:212: undefined reference to `sph_shavite512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:213: undefined reference to `sph_shavite512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:214: undefined reference to `sph_shavite512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:216: undefined reference to `sph_simd512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:217: undefined reference to `sph_simd512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:218: undefined reference to `sph_simd512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:220: undefined reference to `sph_echo512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:221: undefined reference to `sph_echo512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:222: undefined reference to `sph_echo512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:224: undefined reference to `sph_hamsi512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:225: undefined reference to `sph_hamsi512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:226: undefined reference to `sph_hamsi512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:228: undefined reference to `sph_fugue512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:229: undefined reference to `sph_fugue512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:230: undefined reference to `sph_fugue512_close'
collect2: error: ld returned 1 exit status
make(2): *** (Makefile:7370: bitcoin-tx) Error 1
make(2): *** Waiting for unfinished jobs....
/usr/bin/ld: libbitcoin_consensus.a(libbitcoin_consensus_a-block.o): in function `uint256 HashX13sm3<char*>(char*, char*)':
/home/gilsun91/bitcoin-0.20/src/./hash.h:178: undefined reference to `sph_blake512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:179: undefined reference to `sph_blake512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:180: undefined reference to `sph_blake512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:182: undefined reference to `sph_bmw512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:183: undefined reference to `sph_bmw512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:184: undefined reference to `sph_bmw512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:186: undefined reference to `sph_groestl512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:187: undefined reference to `sph_groestl512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:188: undefined reference to `sph_groestl512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:190: undefined reference to `sph_skein512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:191: undefined reference to `sph_skein512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:192: undefined reference to `sph_skein512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:194: undefined reference to `sph_jh512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:195: undefined reference to `sph_jh512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:196: undefined reference to `sph_jh512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:198: undefined reference to `sph_keccak512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:199: undefined reference to `sph_keccak512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:200: undefined reference to `sph_keccak512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:204: undefined reference to `sm3_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:205: undefined reference to `sph_sm3'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:206: undefined reference to `sph_sm3_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:208: undefined reference to `sph_cubehash512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:209: undefined reference to `sph_cubehash512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:210: undefined reference to `sph_cubehash512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:212: undefined reference to `sph_shavite512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:213: undefined reference to `sph_shavite512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:214: undefined reference to `sph_shavite512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:216: undefined reference to `sph_simd512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:217: undefined reference to `sph_simd512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:218: undefined reference to `sph_simd512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:220: undefined reference to `sph_echo512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:221: undefined reference to `sph_echo512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:222: undefined reference to `sph_echo512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:224: undefined reference to `sph_hamsi512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:225: undefined reference to `sph_hamsi512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:226: undefined reference to `sph_hamsi512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:228: undefined reference to `sph_fugue512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:229: undefined reference to `sph_fugue512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:230: undefined reference to `sph_fugue512_close'
collect2: error: ld returned 1 exit status
make(2): *** (Makefile:7374: bitcoin-wallet) Error 1
/usr/bin/ld: libbitcoin_consensus.a(libbitcoin_consensus_a-block.o): in function `uint256 HashX13sm3<char*>(char*, char*)':
/home/gilsun91/bitcoin-0.20/src/./hash.h:178: undefined reference to `sph_blake512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:179: undefined reference to `sph_blake512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:180: undefined reference to `sph_blake512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:182: undefined reference to `sph_bmw512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:183: undefined reference to `sph_bmw512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:184: undefined reference to `sph_bmw512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:186: undefined reference to `sph_groestl512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:187: undefined reference to `sph_groestl512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:188: undefined reference to `sph_groestl512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:190: undefined reference to `sph_skein512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:191: undefined reference to `sph_skein512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:192: undefined reference to `sph_skein512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:194: undefined reference to `sph_jh512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:195: undefined reference to `sph_jh512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:196: undefined reference to `sph_jh512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:198: undefined reference to `sph_keccak512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:199: undefined reference to `sph_keccak512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:200: undefined reference to `sph_keccak512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:204: undefined reference to `sm3_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:205: undefined reference to `sph_sm3'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:206: undefined reference to `sph_sm3_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:208: undefined reference to `sph_cubehash512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:209: undefined reference to `sph_cubehash512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:210: undefined reference to `sph_cubehash512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:212: undefined reference to `sph_shavite512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:213: undefined reference to `sph_shavite512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:214: undefined reference to `sph_shavite512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:216: undefined reference to `sph_simd512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:217: undefined reference to `sph_simd512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:218: undefined reference to `sph_simd512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:220: undefined reference to `sph_echo512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:221: undefined reference to `sph_echo512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:222: undefined reference to `sph_echo512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:224: undefined reference to `sph_hamsi512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:225: undefined reference to `sph_hamsi512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:226: undefined reference to `sph_hamsi512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:228: undefined reference to `sph_fugue512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:229: undefined reference to `sph_fugue512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:230: undefined reference to `sph_fugue512_close'
collect2: error: ld returned 1 exit status
make(2): *** (Makefile:7378: bitcoind) Error 1
/usr/bin/ld: libbitcoin_consensus.a(libbitcoin_consensus_a-block.o): in function `uint256 HashX13sm3<char*>(char*, char*)':
/home/gilsun91/bitcoin-0.20/src/./hash.h:178: undefined reference to `sph_blake512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:179: undefined reference to `sph_blake512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:180: undefined reference to `sph_blake512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:182: undefined reference to `sph_bmw512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:183: undefined reference to `sph_bmw512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:184: undefined reference to `sph_bmw512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:186: undefined reference to `sph_groestl512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:187: undefined reference to `sph_groestl512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:188: undefined reference to `sph_groestl512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:190: undefined reference to `sph_skein512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:191: undefined reference to `sph_skein512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:192: undefined reference to `sph_skein512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:194: undefined reference to `sph_jh512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:195: undefined reference to `sph_jh512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:196: undefined reference to `sph_jh512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:198: undefined reference to `sph_keccak512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:199: undefined reference to `sph_keccak512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:200: undefined reference to `sph_keccak512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:204: undefined reference to `sm3_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:205: undefined reference to `sph_sm3'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:206: undefined reference to `sph_sm3_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:208: undefined reference to `sph_cubehash512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:209: undefined reference to `sph_cubehash512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:210: undefined reference to `sph_cubehash512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:212: undefined reference to `sph_shavite512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:213: undefined reference to `sph_shavite512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:214: undefined reference to `sph_shavite512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:216: undefined reference to `sph_simd512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:217: undefined reference to `sph_simd512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:218: undefined reference to `sph_simd512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:220: undefined reference to `sph_echo512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:221: undefined reference to `sph_echo512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:222: undefined reference to `sph_echo512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:224: undefined reference to `sph_hamsi512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:225: undefined reference to `sph_hamsi512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:226: undefined reference to `sph_hamsi512_close'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:228: undefined reference to `sph_fugue512_init'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:229: undefined reference to `sph_fugue512'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/./hash.h:230: undefined reference to `sph_fugue512_close'

java – Remove Minecraft formatting codes from a String

I obtain strings that contain chat messages, and they sometimes have formatting codes imbedded in them. A formatting code is a § followed by a character, and this character then defines how the code will affect the following text. Colour codes can occur at the very end of the String, a common case of a message would be:

"§r§aThis is a message.§r§bAnd this is blue...§r"

Currently I’m using this method, which simply iterates over the String and skips another character when it encounters a §. Is this a good solution, and how can I further improve it?

private String cleanFormattingCodes(String message) {
    StringBuilder newMessage = new StringBuilder();
    for (int i = 0; i < message.length(); i++) {
      char c = message.charAt(i);
      if (c == '§') {
        i++;
        continue;
      }

      newMessage.append(c);
    }
    return newMessage.toString();
  }

Why some codes can be executed by creating an object file through compiler while some codes need an interpreter to be executed?

We can execute a c/cpp file by creating an object file through compilation.But why do we need to pass java bytecodes through an interpreter to execute them?What’s the differentiating feature that makes interpreter necessary to execute java bytecoes?