Frage

obj\Debug\src\SQLite3DB.o||In function _static_initialization_and_destruction_0:|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|222|undefined reference to boost::system::generic_category()|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|223|undefined reference to boost::system::generic_category()|
D:\workspace-cpp\boost_1_54_0_beta1\boost\system\error_code.hpp|224|undefined reference to boost::system::system_category()|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 4 seconds) ===|

Above is my full error message after including boost/filesystem.hpp to my project. I saw some posts which said that adding -lboost_system might solve this, but I have no idea where to do that in CodeBlocks!
I have already spent one day on solving this problem. Thanks for your help!

War es hilfreich?

Lösung

Right click on the project name; click "Build options..."; go to "Linker settings"; click "Add"; find the library and add it.

enter image description here enter image description here enter image description here enter image description here

Additionally, you may add some custom variables to ease the management of debug/release and 32/64bit target options. I'll leave that to you.


EDIT

Here is the erroneous code from error_code.hpp:

# ifndef BOOST_SYSTEM_NO_DEPRECATED
    inline const error_category &  get_system_category() { return system_category(); }
    inline const error_category &  get_generic_category() { return generic_category(); }
    inline const error_category &  get_posix_category() { return generic_category(); }
    static const error_category &  posix_category = generic_category();
    static const error_category &  errno_ecat     = generic_category();
    static const error_category &  native_ecat    = system_category();
# endif

As you can see, defining BOOST_SYSTEM_NO_DEPRECATED will disable it. I have tested that and it works. This compiles:

#define BOOST_SYSTEM_NO_DEPRECATED
#include <boost/system/error_code.hpp>

int main(void)
{

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top