open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Compiler problems on Solaris 10

ITworld.com 10/25/06

Sandra Henry-Stocker, ITworld.com

Send in your Unix questions today! | See additional Unix tips and tricks

Digg!

I recently decided that it was time that I learn a little C+ +. After all, I studied Computer Science back when Unix was a toddler and now have a daughter who is taking Math and Computer Science classes at UCLA. So, I started with a typical "hello, world" kind of program and tried to compile it on my newly installed Solaris 10 system. But, instead of an easy compilation of my embarrassingly simple program, I ran into a series of errors:

boson> c++ easy.c
In file included from /usr/include/sys/wait.h:24,
                 from /usr/include/stdlib.h:22,
                 from /usr/local/include/c++/3.3.2/cstdlib:52,
                 from /usr/local/include/c++/3.3.2/bits/stl_algobase.h:67,
                 from /usr/local/include/c++/3.3.2/memory:54,
                 from /usr/local/include/c++/3.3.2/string:48,
                 from /usr/local/include/c++/3.3.2/bits/locale_classes.h:47,
                 from /usr/local/include/c++/3.3.2/bits/ios_base.h:47,
                 from /usr/local/include/c++/3.3.2/ios:49,
                 from /usr/local/include/c++/3.3.2/ostream:45,
                 from /usr/local/include/c++/3.3.2/iostream:45,
                 from easy.c:1:
/usr/include/sys/siginfo.h:259: error: 'ctid_t' is used as a type, but is not
   defined as a type.
/usr/include/sys/siginfo.h:390: error: 'ctid_t' is used as a type, but is not
   defined as a type.
"What is wrong with my signinfo.h file?" I wondered, looking at the traceback. And, since the system will soon be replacing a development system, I couldn't help but imagine my inability to compile the simplest possible program was a bad omen for the box when it was turned over to people who program fifty hours a week.

The program, as you'll see from the text below, has only one significant line of code -- the equivalent of a printf statement. How this modest program engendered an error in a signal header file was beyond my grasp.

#include <iostream>

int main()
{
        std::cout << "Welcome to the wonderful world of C++!!!\n";
        return 0;
}
After some googling, I determined that the problem that I was experiencing related to a conflict between my Solaris 10 and gcc package's header files. Fortunately, I also discovered that I could rebuild gcc's 'adapted' headers by running a script already available on my system. When I ran a find, I found two versions, very similar but not identical.

bash-3.00# find /usr -name mkheaders -print
/usr/sfw/libexec/gcc/sparc-sun-solaris2.10/3.4.3/install-tools/mkheaders
/usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/install-tools/mkheaders
boson> /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/install-tools/mkheaders
fixproto: populating `/usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include'
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/evolution-1.4)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root/usr)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root/usr/openwin)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root/usr/openwin/share)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root/usr/openwin/share/include)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/root/usr/openwin/share/include/X11)
(No *.h files in /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/include/X11)
I was then able to compile my program without problems.

make easy
c++    -o easy easy.c
When I tried to run the program, however, I ran into a problem. The loader couldn't find a needed library -- libstdc++.so.5:

bash-3.00# ./easy
ld.so.1: easy: fatal: libstdc++.so.5: open failed: No such file or directory
Killed
Searching, I found several libraries by that name:

# find /usr -name "libstdc++.so.5" -print
/usr/lib/AdobeReader/Reader/sparcsolaris/lib/libstdc++.so.5
/usr/local/lib/libstdc++.so.5
/usr/local/lib/sparcv9/libstdc++.so.5
To verify that my program would run properly with the previously "missing" library, I added two of the paths to my LD_LIBRARY_PATH variable:

export LD_LIBRARY_PATH:/usr/local/lib:/usr/sfw/lib
At this point, my program ran properly.

boson> ./easy
Welcome to the wonderful world of C++!!!
Using the crle (configure runtime linking environment) command, I verified that neither of these paths was configured as a system-wide default:

boson> crle

Default configuration file (/var/ld/ld.config) not found
  Default Library Path (ELF):   /lib:/usr/lib  (system default)
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)
I then used the crle command (very cautiously!) and added the new paths. With this change, I will not need to configure the LD_LIBRARY_PATH variable for the users on this system.

# crle -l /lib:/usr/lib:/usr/local/lib:/usr/local/lib/sparcv9
I then ran crle again to confirm the change:

# crle

Configuration file [version 4]: /var/ld/ld.config
  Default Library Path (ELF):   /lib:/usr/lib:/usr/local/lib:/usr/local/lib/sparcv9
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

Command line:
  crle -c /var/ld/ld.config -l /lib:/usr/lib:/usr/local/lib:/usr/local/lib/sparcv9
Running crle also created a /var/ld/ld.config file on my system to retain the modified library path through system reboots.

# more /var/ld/ld.config
X/lib:/usr/lib:/usr/local/lib:/usr/local/lib/sparcv9
To be triple sure that the system was doing everything as it should, I unset my LD_LIBRARY_PATH variable and ran my simple program again.

unset LD_LIBRARY_PATH
./easy
Welcome to the wonderful world of C++!!!

On this topic

 

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
Sun Microsystems' - FREE 60 DAY TRIAL OFFER!
Test Sun's Newest Servers BEFORE YOU BUY. Plug Them In With Access To Full Technical Support.
100% Web Based Help Desk Software
Easy to use, customizable to meet your needs, powerful and scalable. Free online demo. Try it today!
Sign up for a Microsoft Dynamics® CRM WEBCAST
Hear globally recognized leaders in customer strategy discuss the importance and evolution of CRM.
Used and Refurbished HP ProCurve Switches
Lifetime Warranties, Professional Testing & Shipping on all HP Equipment Purchases!
» Buy a link now

Advertisements
Sponsored links
Locate Hidden Software on business PCs with this free tool
Bring harmony to your mix of UNIX-Linux-Windows computing environments
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
 Home   Open source  Operating systems  Unix
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.