- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Managing Shared Libraries in Makefile
Operating System - Linux
1820635
Members
1783
Online
109626
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО01-11-2008 05:09 AM
тАО01-11-2008 05:09 AM
Managing Shared Libraries in Makefile
Hi All,
I have the following problem while linking the shared library. can some one help me to solve this problem.
The Directory structure for my project is as below
MAIN -
WorkSpace -
DIR1 - Src
Hdr
lib
obj
DIR2 - Src
Hdr
lib
obj
DIR3 -Src
..
..
Workspace is the directory where i am copying all the shared libraries and the executable. My main function is present in DIR3/Src
So initillay i generated the shared libraries for each DIRs in their respective lib directories and copied it to WorkSpace in the Makefile of each directory
Now while generating the executable, in DIR3/Src/Makefile i i have specified to take the libraries present in the
../../WorkSpace
But, I am getting
ld errors because the compiler is not getting the Path. But if i give
/home/Vikram/MAIN/WorkSpace, it works.
Can any one help me to solve this problem.
Also, if i hard core the paths like this can i use the executable generated in WorkSpace as a standaloner in some other Machine.
thanks and regards
Vikram
I have the following problem while linking the shared library. can some one help me to solve this problem.
The Directory structure for my project is as below
MAIN -
WorkSpace -
DIR1 - Src
Hdr
lib
obj
DIR2 - Src
Hdr
lib
obj
DIR3 -Src
..
..
Workspace is the directory where i am copying all the shared libraries and the executable. My main function is present in DIR3/Src
So initillay i generated the shared libraries for each DIRs in their respective lib directories and copied it to WorkSpace in the Makefile of each directory
Now while generating the executable, in DIR3/Src/Makefile i i have specified to take the libraries present in the
../../WorkSpace
But, I am getting
ld errors because the compiler is not getting the Path. But if i give
/home/Vikram/MAIN/WorkSpace, it works.
Can any one help me to solve this problem.
Also, if i hard core the paths like this can i use the executable generated in WorkSpace as a standaloner in some other Machine.
thanks and regards
Vikram
- Tags:
- shlib
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2008 09:09 PM
тАО01-11-2008 09:09 PM
Re: Managing Shared Libraries in Makefile
This is related to your makefile questions.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1192611
>The directory structure for my project is as below
(You can't rely on spacing here unless you check the box. So you should list the full paths for each line.)
>I am getting ld errors because the compiler is not getting the Path.
No compilers are involved. Just ld.
Are you using -L with the correct relative path?
>if i hard code the paths like this, can I use the executable generated in WorkSpace as a standaloner in some other Machine.
Yes, there are several options.
You can use -Wl,+b,path-list to embed the location at runtime.
You can use -Wl,+s so that dld can honor SHLIB_PATH or LD_LIBRARY_PATH at runtime.
For newer linkers, you can also use $ORIGIN in the paths to it is relative to the executable.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1192611
>The directory structure for my project is as below
(You can't rely on spacing here unless you check the box. So you should list the full paths for each line.)
>I am getting ld errors because the compiler is not getting the Path.
No compilers are involved. Just ld.
Are you using -L with the correct relative path?
>if i hard code the paths like this, can I use the executable generated in WorkSpace as a standaloner in some other Machine.
Yes, there are several options.
You can use -Wl,+b,path-list to embed the location at runtime.
You can use -Wl,+s so that dld can honor SHLIB_PATH or LD_LIBRARY_PATH at runtime.
For newer linkers, you can also use $ORIGIN in the paths to it is relative to the executable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 04:17 AM
тАО01-12-2008 04:17 AM
Re: Managing Shared Libraries in Makefile
Hi Dennis,
Yes, i have given the correct Path and i also displayed the contetnt of the WorkSpace Directory where all the libraries are present.
Still the linker will complain about the ld errorrs
But, I am able to compile now by setting the SHLIB_PATH to the workSpace directory.
Please find the sample of Makefile attached which i am using in the DIR3/Src/Makefile.
LINKLIB = ../../libStringTokenizer.so \
../../libStringToNumericals.so \
../../libbvfWriter.so \
../../libReadRawData.so \
../../libReadLayoutData.so \
../../libz.sl
$(TARGET) : ProberData ReadProberData.cpp wcBvfWriter.cpp
test -d $(TARGETDIR) || mkdir -p $(TARGETDIR)
pwd; ls ../../WorkSpace ; $(CXX) -o $@ $(INCPATH) ReadProberData.cpp wcBvfWriter.cpp $(LINKLIB);pwd;
thanks and regards
Vikram
Yes, i have given the correct Path and i also displayed the contetnt of the WorkSpace Directory where all the libraries are present.
Still the linker will complain about the ld errorrs
But, I am able to compile now by setting the SHLIB_PATH to the workSpace directory.
Please find the sample of Makefile attached which i am using in the DIR3/Src/Makefile.
LINKLIB = ../../libStringTokenizer.so \
../../libStringToNumericals.so \
../../libbvfWriter.so \
../../libReadRawData.so \
../../libReadLayoutData.so \
../../libz.sl
$(TARGET) : ProberData ReadProberData.cpp wcBvfWriter.cpp
test -d $(TARGETDIR) || mkdir -p $(TARGETDIR)
pwd; ls ../../WorkSpace ; $(CXX) -o $@ $(INCPATH) ReadProberData.cpp wcBvfWriter.cpp $(LINKLIB);pwd;
thanks and regards
Vikram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 06:02 PM
тАО01-12-2008 06:02 PM
Re: Managing Shared Libraries in Makefile
You didn't mention specifically if you were on PA or IPF. On PA you should name your shibs as .sl, not .so.
>LINKLIB = ../../libStringTokenizer.so \ ...
The proper way to do this is with -L & -l:
LINKLIB = -L../../WorkSpace -lStringTokenizer \
-lStringToNumericals -lbvfWriter \
-lReadRawData -lReadLayoutData -lz
(The -l option requires .sl for PA.)
If you don't use -l, then +s and +b don't work, without additional chatr(1) magic.
>test -d $(TARGETDIR) || mkdir -p $(TARGETDIR)
No need for test, just do "mkdir -p".
>LINKLIB = ../../libStringTokenizer.so \ ...
The proper way to do this is with -L & -l:
LINKLIB = -L../../WorkSpace -lStringTokenizer \
-lStringToNumericals -lbvfWriter \
-lReadRawData -lReadLayoutData -lz
(The -l option requires .sl for PA.)
If you don't use -l, then +s and +b don't work, without additional chatr(1) magic.
>test -d $(TARGETDIR) || mkdir -p $(TARGETDIR)
No need for test, just do "mkdir -p".
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP