How to get gcc to OS X to work properly and support std libraries like string.h?

  • 0

    I am trying to get gcc to work on my Mac OS X platform, as one of the compiler options on leetcode is C++.

    However my Mac OS X gcc compiler keeps complaining about not being able to find definitions for std classes like vector and string. This makes it quite hard for me to debug my code if leetcode complains about a runtime error.

    I am suspecting if gcc on OS X actually support standard c++ library, and if so, how to set it up so that these compilation errors would go away...

    This is my compiler version:
    $ gcc -v
    Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin12.5.0
    Thread model: posix


  • 0

    I am using OSx and have no such problem.

  • 0

    for C++ code, have you tried g++ instead?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.