- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Create shared library
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
Forums
Discussions
Discussions
Discussions
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
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
09-13-2001 07:35 PM
09-13-2001 07:35 PM
How can I implement a C program to a shared library so that any other C program can call the function in the shared library ?
Regards,
Patrick
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 06:03 AM
09-14-2001 06:03 AM
Re: Create shared library
a compiler line something like :-
aCC -b +z -o main.sl main.cpp
should suffice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 05:08 PM
09-14-2001 05:08 PM
Re: Create shared library
How can I compile another program with this shared library ? Can you show the command line for me ?
Regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 05:27 AM
09-18-2001 05:27 AM
Re: Create shared library
I can come up with.... normally I'd have
stuff like this in a makefile.
stuff.h
-------
#include
void out();
stuff.cpp
---------
#include "stuff.h"
void out()
{
printf("Hello world\n");
};
main.cpp
--------
#include "stuff.h"
int main()
{
out();
return 1;
}
..and then to actually build the things
---------------------------------------
1) aCC -b +z -o libStuff.sl stuff.cpp
2) aCC -L./ -lStuff -o main main.cpp
-L indicates where 'Stuff' lives
-l is the library name, the lib & .sl
gets wrapped around it.
I think that's it.... just make sure if you
try this example everything lives in the
same directory.
Best 'o Luck
Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2001 05:53 PM
09-18-2001 05:53 PM
Re: Create shared library
My system running HP-UX 11.0 and use the cc compiler come from HP. I replace the aCC with cc but it say it does not have the -b option. Do you know how to compile in my environment ?
And, can I add the shared library in a search path ? If so, what environment variable can I set ?
Many thanks,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2001 07:44 AM
09-19-2001 07:44 AM
Re: Create shared library
with the ANSI-C compiler (the bundled cc compiler which comes with HPUX does not support Positin Independant Code), the procedure would be :
cc +z -c -o sub.o sub.c
ld -b sub.o libxxx.sl
mv libxxx.sl $instdir
cc -L $instdir main.c -o main
Regards, Klaus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2001 07:45 AM
09-19-2001 07:45 AM
Solutionfor each source file :
cc +z -c file.c
and then
ld -b -o libmylib.sl file1.o file2.o ....
to use it in building an executable :
cc -L. -lmylib -o myexec myexec.c
you should set the SHLIB_PATH environment variable
when you launch the program.
Blanche
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2001 08:04 AM
09-19-2001 08:04 AM
Re: Create shared library
the right compilation line is :
cc -Wl,+s -L. -lmylib -o myexec myexec.c
Blanche