hi, i need to create a c shared library on unix platform using korn shell. can you provide me with some sample codes please.
thanks

Recommended Answers

All 9 Replies

come on guys, at least tell me a tutorial that teaches shared libraries in c on unix os.

Actually, it is simply to use

gcc -shared -o libmyshared.so file1.o file2.o

Have a look at the gcc manual. http://gcc.gnu.org/onlinedocs/.

The only thing that you will need to be a little careful of is were to put it so that it is system wide. That is normally defined as directories in /etc/ld.so.conf. That means if you put you lib in /usr/local/lib it normally works.

However, you can get round that by using it as

gcc -Wl,-rpath,/home/serk/yourlocallibpath -o finishedProg file.o libmyshared.so

There are a few more options in the manual but really that covers just about everything. (obviously, you put that in your Makefile appropiately)

maybe because i use not unix but aix that command does not executes on my os.

Well seeing as it took you 3 days to post some actual useful information about the problem, perhaps you could point us to an online manual for the compiler which you're having trouble reading.

Better yet, show us that you've tried to understand the manual by pasting some actual commands tried, and the results you got.

Well seeing as it took you 3 days to post some actual useful information about the problem, perhaps you could point us to an online manual for the compiler which you're having trouble reading.

Better yet, show us that you've tried to understand the manual by pasting some actual commands tried, and the results you got.

what you say is just easy to say for me because i started this c and c++ thing so recent. i need some one who can tell the things from a c# programmer's stand point. for an example i can ask you this : in c# we have dll files to share functionality, whereas in c there are include files and libraries, i just wonder if you can share functionality with include files(at least header files) why do you need to create a library with .a extention. i think i havent seen the big picture yet. i also wonder the future of c and c++. compared to c# they are so slow to create some useful stuff. i consider future of these languages because i dont want to invest time learning all the details if those details will be all obsolete in 2-3 years. what do you think?

I think your estimation of C and C++'s imminent demise is overrated.

Nobody is going to be writing an entire OS / mobile phone / any other handheld consumer electronic device entirely in C# any time soon.

I think your estimation of C and C++'s imminent demise is overrated.

Nobody is going to be writing an entire OS / mobile phone / any other handheld consumer electronic device entirely in C# any time soon.

sooner or later OS can be written in c# using some special frameworks.

By the way Salem, i think i use VisualAge C++ professional / and C for AIX Compiler, Version 6 .

Tell me some useful information about these please..

Anyway thank you Salem, i found some useful information to get away with VisualAge compiler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.