- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Linking shared libraries
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
08-28-2006 10:20 PM
08-28-2006 10:20 PM
Linking shared libraries
[preetam@cyclone]junkc> ls
main.c test.c
[preetam@cyclone]junkc> gcc -c -fPIC test.c
[preetam@cyclone]junkc> gcc -shared -o libtest.so test.o
[preetam@cyclone]junkc> gcc -c main.c
[preetam@cyclone]junkc> set LD_LIBRARY_PATH=(${LD_LIBRARY_PATH}:/h/preetam/junkc)
[preetam@cyclone]junkc> echo $LD_LIBRARY_PATH
/usr/lib:/usr/local/lib:/h/preetmo/junkc
[preetam@cyclone]junkc> gcc -o mainprog main.o -L. -ltest
[preetam@cyclone]junkc> mainprog
ld.so.1: mainprog: fatal: libtest.so: open failed: No such file or directory
Killed
Please let me know what is wrong with it??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 11:16 PM
08-28-2006 11:16 PM
Re: Linking shared libraries
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2006 11:48 PM
08-28-2006 11:48 PM
Re: Linking shared libraries
can you check with 'ldd mainprog' and 'chatr mainprog' where the program expects the shared libraries?
Then create a link or add the directory to your env PATH.
Maybe you have to set your LD_LIBRARY_PATH in the program?
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 03:51 PM
08-29-2006 03:51 PM
Re: Linking shared libraries
I used ldd mainprog and below is the output
[preetam@cyclone]junkc> ldd mainprog
libtest.so => (file not found)
libc.so.1 => /usr/lib/libc.so.1
libdl.so.1 => /usr/lib/libdl.so.1
/usr/platform/SUNW,Ultra-4/lib/libc_psr.so.1
For chatr command was not found.
I have updated the LD_LIBRARY_PATH as mentioned in the previous post to my current directory but it still doesnt work. I have also tried giving the path to gcc in the command line as follows:
[preetam@cyclone]junkc> gcc -o mainprog shared.o -L. -ltest -Wl,-rpath,/h/preetam/libtest
but it still doesnt work.
I read somewhere that there is an alternative method to regenerate the library cache file by typing "ldconfig" in the installed directory. But my system does not have even that command!!! :(
I am using SunOS 5.8
Preetam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 05:42 PM
08-29-2006 05:42 PM
Re: Linking shared libraries
gcc -o mainprog main.o -L. -L/h/preetmo/junkc -ltest
As far as i remember
LD_LIBRARY_PATH is not used during searching of libraries.
Its used during run-time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 07:35 PM
08-29-2006 07:35 PM
Re: Linking shared libraries
I don't know how to use 'gcc', but maybe you have to give the complete path of 'libtest.so' when you declare it as a library.
Where have you stored it, in your home dir?
Maybe you also can create a link in /usr/lib to 'libtest.so', also I think it's not the 'clean' way to do it.
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 10:42 PM
08-29-2006 10:42 PM
Re: Linking shared libraries
I tried what you said. Same result!! does not work...
Volkmar I cant create a link in /usr/lib as it is on a different file system. I used command ln -f ~/junkc/libtest.so
Regards,
Preetam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 10:50 PM
08-29-2006 10:50 PM
Re: Linking shared libraries
for a short test - copy libtest.so into /usr/lib and see if it works.
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 10:58 PM
08-29-2006 10:58 PM
Re: Linking shared libraries
On HP-UX, if you have exported the PWD in LD_LIBRARY_PATH it should just work. Not knowing if you are using a "real" shell or not, I don't think "set" exports the variable?? The scummy C shell requires setenv. A "real" shell requires export.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 11:03 PM
08-29-2006 11:03 PM
Re: Linking shared libraries
I think his 'set' worked, because in his 'echo' you can see the added path.
V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2006 11:25 PM
08-29-2006 11:25 PM
Re: Linking shared libraries
I first thought so too but that is not how shell variables work. You should use the env(1) command and see if the variable is exported. Using any command with a $variable will just have the shell expand it without exporting it.
$ csh # start scummy C shell
% set xxx=yyy
% echo $xxx # this command proves nothing
yyy
% env | fgrep xxx
% setenv xxx "$xxx"
% env | fgrep xxx # now part of the environment
xxx=yyy
- Tags:
- scummy C shell