Cpp errors

From PeerFreedom Wiki
Jump to navigation Jump to search

Post here common errors in C++ (in compilation, linking, etc) - error message plus the solution/description.

So that we can learn common errors to quickly identify them - mostly do post hard errors, that are not very obvious what is causing them.

  • The function has been compiled more than once. Most likely the implementation is in the hpp file. Should be in cpp.
/home/user/work/proje/depends/pfp-cpp/include/pfp-cpp/wallet/transaction.hpp:52: error: multiple definition of `n_pfp::n_crypto::operator<<(std::ostream&, n_pfp::n_crypto::t_coin_txid_output const&)'; CMakeFiles/tests.dir/src-test/test_wallet_coinnode.cpp.o:/home/user/work/proje/depends/pfp-cpp/include/pfp-cpp/wallet/transaction.hpp:52: first defined here
  • Use colorized warning/errors on the console when compilator works
  • If compiler set the -Werror flag (meanings all warnings treat as errors), you can unset some flags by set the variable -Wno-error=[...] (in other words, this restore the error to the warning)