-
February 17th, 2011, 04:41 PM
#1
[RESOLVED] Dynamic/static linking question
On a linux system, is it possible to link with both static and dynamic libraries (different libraries, of course) at the same time? I used to do this on a Solaris platform but have been unsuccessful on linux. I can build an executable using all dynamic libraries, or with all static libraries, but I can't mix them up. Is this strictly unique to Solaris? If it is possible, can someone please show me what combination of compiler/linker flags are necessary, and how to use them. Thanks.
Note: This is with the gnu g++ compiler.
-
February 17th, 2011, 09:40 PM
#2
Re: Dynamic/static linking question
If you simply specify the name of the library file on the command line (ending in .a for static or .so for dynamic), the corresponding library will be linked.
-
February 17th, 2011, 11:24 PM
#3
Re: Dynamic/static linking question
g++ o my.c my( executable ) -lcairo
where cairo the the lib you are trying to link to , I do not know if there a a solaris build for Netbeans m if there is then download the C++ edition , Netbeans automates a lot of building process.
-
February 18th, 2011, 10:05 AM
#4
Re: Dynamic/static linking question
If you use the -l method of linking, then the compiler will look for either a .a or a .so with the proper name and you have little control over which it chooses. Specifying the library name entirely guarantees which one is used.
-
March 14th, 2011, 12:31 PM
#5
Re: Dynamic/static linking question
Originally Posted by Lindley
If you simply specify the name of the library file on the command line (ending in .a for static or .so for dynamic), the corresponding library will be linked.
Sorry for not getting back to you sooner on this (just been extremely busy lately). Anyway, thanks for the info, it worked perfect. I didn't realize you could directly specify the library name in the compilation/link command. I kept trying to use combinations of the -static and -shared options, along with the -l option. Thanks again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|