- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need to compile a shared library with gcc-2.95...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2000 06:14 AM
тАО11-15-2000 06:14 AM
Need to compile a shared library with gcc-2.95.2 on HP-UX
I have HP-UX 10.2 running on C110 machine. I have the bundled HP-C compiler as listed below.
_____________________________________________
#what /usr/ccs/bin/cc
/usr/ccs/bin/cc: HP92453-01 A.10.32.00 HP C (Bundled) Compiler
/usr/lib/libc: $Revision: 76.3 $
_____________________________________________
I have gcc-2.95.2 properly installed on the machine. I am trying to create a "shared" library using gcc. The object modules are produced from a bunch of *.cpp (c++) files using "gcc -c -fpic *.cpp". However, when I try to link them with the following command
"gcc -shared *.o -o x.sl", I get the following message:
___________________________________________
/usr/ccs/bin/ld: DP relative code in file /var/tmp/cc4cnn5b.o - shared
library must be position independent. Use +z or +Z to recompile.
collect2: ld returned 1 exit status
___________________________________________
I recognize that the +z or +Z are the options on the HP ANSI C compiler and not gcc.
If I link explicitly with "ld" (ld -b *.o -o x.sl), it creates a library, however, it seems it is incorrectly built. As a matter of fact, in the HP documentation, it is explicitly stated that "ld" should not be used to generate shared libraries with c++ code, but rather cc should be used.
Any pointers on what I am doing wrong or what I need to do differently?
Thanks for your time.
Avinash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2000 06:53 AM
тАО11-15-2000 06:53 AM
Re: Need to compile a shared library with gcc-2.95.2 on HP-UX
Tricky problem.
I wouldnt be too concerned about the HP docs saying your should use cc to create a library for c++ code. Sounds like a marketing ploy to me, so that HP require you to load/buy the HP c++ compiler in addition/instead of the Ansi/C compiler. As you pointed out, using gcc you can create the object files just fine, and ld creates the library fine, so no problem. You cant use gcc to create the library direct because ld expects an HP compiler, not the gnu one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2000 07:14 AM
тАО11-15-2000 07:14 AM
Re: Need to compile a shared library with gcc-2.95.2 on HP-UX
Thanks for your input. Is there a way to check for "integrity/correctness/consistency" of the shared library that I created with explicitly using "ld" ? The following quote is directly from the "Compiler-Linker Interaction" section of the HP manual "http://docs.hp.com/hpux/onlinedocs/B2355-90655/B2355-90655.html". My concern stems from the statement that "you may not get any error messages". I am not sure whether my failure in using the shared library is a result of the what is stated below or something else. Hence my question above regarding "correctness". Thanks for your time.
Regards
Avinash
______________________________________________
If you are linking any C++ object files to create an executable or a shared library, you must use the CC command to link. This ensures that c++patch executes and chains together your nonlocal static constructors and destructors. If you use ld, the library or executable may not work correctly and you may not get any error messages. For more information see the HP C++ Programmer's Guide .
_____________________________________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 06:52 AM
тАО11-17-2000 06:52 AM
Re: Need to compile a shared library with gcc-2.95.2 on HP-UX
This is exactly what gcc is trying to do. In order to do this it compiles a C fix up module and then adds that to your library link. It must build this as PIC which it currently isn't and ld is consequently complaining about it. Therefore, add "-fpic" to the link line so that when it propagates the arguments down it knows to do this. That is:
gcc -fpic -shared *.o -o x.sl
Andy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 12:59 PM
тАО11-17-2000 12:59 PM
Re: Need to compile a shared library with gcc-2.95.2 on HP-UX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2000 02:25 PM
тАО11-20-2000 02:25 PM
Re: Need to compile a shared library with gcc-2.95.2 on HP-UX
Thanks for your input. Will post any progress I make in this regard.
Avinash