-std=c++11 or -std=gnu++0x

Rainer Müller raimue at macports.org
Sun Feb 2 03:09:25 PST 2014


On 2014-02-02 10:19, Christopher Dawes wrote:
> #include <stdio.h>
> #include <ctype.h>
> #include <string>

Unrelated, but in C++ you should use <cstdio> and <cctype> instead of
the .h files.

> Now trying to compile gives:
> chrisd$ g++ -std=c++11 -o test test.cpp
> Undefined symbols for architecture x86_64:
>   "isalnum(int)", referenced from:
>       _main in ccDuU6gp.o
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status

There is a problem with the header files shipped with OS X. This is
tracked in this ticket:

  http://trac.macports.org/ticket/41033

The problem only exists with the combination of g++-mp-4.* and
-std=c++11, compiling earlier C++ code using g++-mp-4.* should work. The
best known workaround is to use clang++ instead of g++ for C++11 code.

Rainer


More information about the macports-users mailing list