EDIT: I suppose I should clarify, in case that matters. I am on AIX Unix, so I use VAC compilers - no gnu compilers.
End editing
I'm pretty rusty in C / C ++, so forgive me if this is a simple question.
I would like to use common functions from several of my C programs and put them in shared libraries or shared objects. If I did this in perl, I would put my submarines in the perl module and use this module if necessary.
For example, suppose I have this function:
int giveInteger()
{
return 1034;
}
Obviously, this is not an example of the real world, but if I wanted to share this function, how could I continue?
I am sure that I have 2 options:
?
If so, how can I use both of these methods? I searched a lot, and it seems to me that I find information on how I can link my own program to another shared library, but not how to create my own common functions and compile them so that I can use them in my own program .
Many thanks!
Brian
EDIT:
Conclusion
Thank you all for your help! I thought I would add to this post what works for me (for dynamic shared libraries on AIX) so that others can benefit:I will compile my general functions:
xlc -c sharedFunctions.c -o sharedFunctions.o
Then make it a shared object:
xlc -qmkshrobj -qexpfile=exportlist sharedFunctions.o
xlc -G -o libsharedFunctions.so sharedFunctions.o -bE:exportlist
Then link it to another program:
xlc -brtl -o mainProgram mainProgram.c -L. -lsharedFunctions
, :
http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/topic/com.ibm.vacpp7a.doc/proguide/ref/compile_library.htm
, !