The charm of Sun's Freeware collection

February 10, 2006

Presented on a stock install Solaris 9:

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

    cout << "Hello World!\n";
$ g++ hello.cpp
$ ./a.out a.out: fatal: \
  open failed: No such file or directory

(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.

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, Add Comment.
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.