Adding Boost Library to a C++ project in OS X Eclipse

前端 未结 5 624
無奈伤痛
無奈伤痛 2021-02-06 02:41

I am have been attempting to get a C++ project setup using boost file system library using eclipse. I followed these directions to install boost on my system. The directions whe

5条回答
  •  执笔经年
    2021-02-06 03:27

    I had recently uninstalled the boost rpm and installed Boost like how you did. I had no problems running Boost programs in Eclipse. I didn't add any extra parameters. Just installed boost and ran Boost programs. It works fine.

    Tried your program in the vi editor. Commented out everything in main

    #include 
    #include 
    
    int main() {
        /*boost::filesystem::path path("/Users/schoen"); // random pathname
        bool result = boost::filesystem::is_directory(path);
        printf("Path is a directory : %d\n", result);*/
        return 0;
    }
    

    and it still gave this error:

    /tmp/cc7TAIYS.o: In function `__static_initialization_and_destruction_0(int, int)':
    test.cpp:(.text+0x29): undefined reference to `boost::system::get_system_category()'
    test.cpp:(.text+0x35): undefined reference to `boost::system::get_generic_category()'
    test.cpp:(.text+0x41): undefined reference to `boost::system::get_generic_category()'
    test.cpp:(.text+0x4d): undefined reference to `boost::system::get_generic_category()'
    test.cpp:(.text+0x59): undefined reference to `boost::system::get_system_category()'
    collect2: ld returned 1 exit status
    

    I'm puzzled. Boost programs work on my system, but your program's header files itself are giving a problem. I doubt it's a problem with Eclipse. It has to be something else.

提交回复
热议问题