The charm of Sun's Freeware collection

February 10, 2006

Presented on a stock install Solaris 9:

$ cat hello.cpp
#include <iostream.h>

main()
{
    cout << "Hello World!\n";
}
$ g++ hello.cpp
$ ./a.out
ld.so.1: a.out: fatal: libstdc++.so.2.10.0: \
  open failed: No such file or directory
Killed

(Line wrapping added for clarity.)

To get the Sun Freeware g++ working, the magic solution is 'g++ -Wl,-R/opt/sfw/lib ...', which adds /opt/sfw/lib (where the necessary g++ internal library is) to the runtime shared library lookup path.

The irony here is that the Sun Freeware g++ has already been configured to look in /opt/sfw/lib (or it would report a compile time error about not being able to find the library). But nobody went the extra step to add it to the default runtime path, and no one bothered to test the Freeware g++ before they shipped it.

If I have to use g++ on Solaris much, I expect I'll just write a cover script for gcc and g++ that just always adds that argument. (Or replace the g++ version entirely, since it is gcc 2.95.3.)

Update: courtesy of the htdig FAQ, another workaround is to set the LD_RUN_PATH environment variable to /opt/sfw/lib when you compile stuff.


Comments on this page:

From 24.98.83.96 at 2006-02-11 13:48:53:

This seems silly, and Sun should have checked for this prior to shipping the freeware collection. Could you could post a bug on opensolaris.org? Sun is usually pretty good about fixing stuff like this.

- Ryan http://daemons.net/~matty

By cks at 2006-02-11 15:29:58:

At first I figured that opensolaris.org would be the wrong place to report a problem with Solaris 9, but a search through their bug database does show at least some Solaris 9 bugs. Not that they made this easy to find out. (There are all sorts of things that irritate me about the OpenSolaris bug database page; I will spare everyone by skipping them.)

Unfortunately, the OpenSolaris bug report registration process wants to put me through the third degree, including asking me to come up with a login (and a password). I need to rant about this sometime, but the short version is 'I don't feel like doing that much work right now'.

Anyone who already has an OpenSolaris bug reporting account and the interest should feel free to file a bug report yourself. I don't mind.

Written on 10 February 2006.
« Session IDs and the Birthday Paradox
The return of how to get your web spider banned »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Feb 10 16:03:26 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.