Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C supports dynamic linking?

Status
Not open for further replies.

subbaraok

Programmer
Sep 28, 2001
2
US
c language supports for dynamic linking or not ?(as c++
supports).How to develop the code for dynamic linking with
the help of c language.Because c++ also in c written c language ,so some possibility is there to develop ,so friend
please give reply if you know this thing.
 
If you're talking about dll's or libraries I'm pretty sure it's supported. However I don't know how to do this myself so I can't help you.
 
Nothing is more easy.
But it is more about linking and compiling then C itself.
Just create your program (that supposed to be dll without main function) compile it and link as dll (see compiler option). On UNIX it will be single file with .so extention on Nt/Win it should be two files .lib and .dll.
On Nt: Lib must be linked with your executable for loading DLL file and DLL file itself should be shiped with your program (no need to include .lib file in your destributable).
On UNIX there is only .so file, so it has to be in linker line for resolving function calls and program should be shiped with the same .so file.

DLL sorece code should have public interface in .h files and this files should be included in your main code to resolved function calls during compilation.

That is it in general. See compiler help for swithches.
 
Nothing is more easy.
But it is more about linking and compiling then C itself.
Just create your program (that supposed to be dll without main function) compile it and link as dll (see compiler option). On UNIX it will be single file with .so extention on Nt/Win it should be two files .lib and .dll.
On Nt: Lib must be linked with your executable for loading DLL file and DLL file itself should be shiped with your program (no need to include .lib file in your destributable).
On UNIX there is only .so file, so it has to be in linker line for resolving function calls and program should be shiped with the same .so file.

DLL sorece code should have public interface in .h files and this files should be included in your main code to resolved function calls during compilation.

That is it in general. See compiler help for switches.
 
thank you lim.my system is Linux system and only GNU c compiler.dear friend i haven't seen these .so files.could you please tell me about this .so file creation.if you tell
this i am very thankfull to you
 
I have no experience with Linux. I am working with UNIX on SGI, SUN, HP and DLL has extension .so (static libraries has extension .a) on these UNIX. Generally you can create any extension for your DLL (you can even use dll as for Nt). Extension on UNIX is not that important as on Nt. I am not sure but in this case you will probably have to load them manually, I don't know if C linker or RLD (run time linker) can load them automatically.
Also I don't know what command line should be for your compiler to create Dynamic Link Library (DLL). Check manual (or man pages) for compiler it should be right there.


 
try this find / -name *.so
I think you will find quite a few.
Also there is a howto for linking that should
have been installed with your distro.
You should look at this and the gcc howto, and man pages. Unfortunately I am a novice C programmer and cannot help you with examples
of linking. If you have ever compiled a kernel you have seen this behavior however..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top