# Mixup of libstdc++ caused by gcc44



## tankist02 (Feb 16, 2010)

The following C++ program crashes when compiled with g++:


```
int main()
{
    try {
        throw 1;
    } catch (int) {
        return 0;
    }
    return 1;
}
```

The error is:


```
terminate called after throwing an instance of 'int'
Abort (core dumped)
```

Running ldd on the executable shows that libstdc++ is from gcc44, not the base compiler:


```
a.out:
        libstdc++.so.6 => /usr/local/lib/gcc44/libstdc++.so.6 (0x800647000)
        libm.so.5 => /lib/libm.so.5 (0x800955000)
        libgcc_s.so.1 => /usr/local/lib/gcc44/libgcc_s.so.1 (0x800a74000)
        libc.so.7 => /lib/libc.so.7 (0x800c80000)
```

If built with g++44 the program runs as expected.

Where should I look to fix that?


----------



## DutchDaemon (Feb 16, 2010)

Why is /usr/local/lib/gcc44/libstdc++.so.6 called before /usr/lib/libstdc++.so.6? The latter should be appearing in [cmd=]ldconfig -r[/cmd] first and be used first. Same goes for /lib/libgcc_s.so.1 vs. /usr/local/lib/gcc44/libgcc_s.so.1, I guess.


----------



## tankist02 (Feb 17, 2010)

Actually base libstdc++ comes first:


```
# ldconfig -r | grep libstdc++
        43:-lstdc++.6 => /usr/lib/libstdc++.so.6
        1003:-lstdc++.6 => /usr/local/lib/gcc44/libstdc++.so.6
```

It looks for some reason g++ links to libstdc++ from g++44, not its own.

BTW this error happens not on one, but on a few computers. All running 8.0 Release p2 amd64.

What else can I check?


----------



## tankist02 (Feb 18, 2010)

Solved the issue - it was my error. At one point I was playing with compiling ports with gcc44:


```
[url=http://www.freebsd.org/doc/en/articles/custom-gcc/article.html]http://www.freebsd.org/doc/en/articles/ ... ticle.html[/url]
```

and forgot to delete /etc/libmap.conf that points to gcc44 shared libraries. Sorry for the noise, next time I'll keep a log of what I did with the system...


----------

