Using -std=c++11 with the macports gcc-4.7 compiler

Sean Farley sean at macports.org
Tue Jan 15 08:52:30 PST 2013


On Mon, Jan 14, 2013 at 8:32 AM, David Barto <DBarto at visionpro.com> wrote:
> fails because the /usr/lib/libstdc++.so is found first. What can I do to
> find the proper /opt/local/lib/libstdc++.so?
>
> I've not modified the search paths in any way, I'm just trying to compile a
> c++ program using the newer standard features.

Hmm, I can't reproduce this error. Using no special environment
variables and just a vanilla install of gcc47 on Mountain Lion, I get:

$ g++-mp-4.7 -std=c++11 test11.cxx && ./a.out
Hello world

$ otool -L a.out
a.out:
/opt/local/lib/libstdc++.6.dylib (compatibility version 7.0.0, current
version 7.17.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 169.3.0)
/opt/local/lib/gcc47/libgcc_s.1.dylib (compatibility version 1.0.0,
current version 1.0.0)

# shamelessly stolen from
http://www.cprogramming.com/c++11/c++11-lambda-closures.html
$ cat test11.cxx
#include <iostream>

using namespace std;

int main()
{
    auto func = [] () { cout << "Hello world" << endl; };
    func(); // now call the function
}


More information about the macports-users mailing list