1

I am trying to create a library (static or shared) that has only a specified functionality accessible for those who use that library. If I generate the library as follows, all functions implemented in the library are usable from an external application. Can I hide some functions?

gcc -fPIC -g -c -Wall -I/usr/include/extrernalLibDIR modulo1.c
gcc -fPIC -g -c -Wall modulo2.c
gcc -fPIC -g -c -Wall modulo3.c
gcc -shared -Wl,-soname,libMyLib.so.1 -o libMyLib.so.1.0.1 modulo1.o modulo2.o modulo3.o -lc
gcc -g -Wall main.c -o app -I/usr/include/PCSC/ -lMyLib -lpcsclite

And another question: what should I do to avoid having to include a third party library (libpcsclite) that uses my library just created? I wonder if I generate in my library including libpcsclite library.

Pretty grateful!!

hyde
  • 60,639
  • 21
  • 115
  • 176
crossmax
  • 346
  • 3
  • 20
  • 4
    You need `-fvisibility`. See e.g. http://stackoverflow.com/questions/2222162/how-to-apply-gcc-fvisibility-option-to-symbols-in-static-libraries – Erik Jun 05 '14 at 08:36
  • Thanks!! Finally I used EXPORT within sources files and -fvisibility=hidden in gcc. Prototypes are visible with the nm command but will not be available if they are not exported. Now I'm looking for ways to include third party library in my lib for not having to include it with my library to create a program – crossmax Jun 05 '14 at 11:02
  • possible duplicate of [Limiting visibility of symbols when linking shared libraries](http://stackoverflow.com/questions/435352/limiting-visibility-of-symbols-when-linking-shared-libraries) – ninjalj Jun 05 '14 at 18:31

0 Answers0