public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* export symbols
@ 2009-04-23 22:43 Alberich de megres
  2009-04-24  3:43 ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Alberich de megres @ 2009-04-23 22:43 UTC (permalink / raw)
  To: gcc-help

Hi,

i got a question about exporting symbols:

two files:

main.c: defines main and f1() and load module on b.c file ( compiled )
b.c : defines f2() which uses f1() after been loaded.

to compile b.c file i use:
gcc -shared -fPIC b.c -o b.so

And to compile main.c:
gcc main.c -o main -ldl -rdynamic

Everything works fine, but  -rdynamic affects to all symbols on main.c

but i just want to export some of symbol on main.c. Is it some way to
control which symbols i export?

here are source code for main.c

-------------------------------------------------------------------
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv)
{
	int *handler;
	double (*cosine)(double);

	handler=(int*)dlopen("dym.mo", RTLD_LAZY);
	if (!handler) {
		printf( "!!! %s\n", dlerror() );
		return;
  	}
	cosine = dlsym(handler, "cos");
	

	printf("coseno 1 =>%f",cosine(1));

	return 0;

	dlclose(handler);
	
}

int f1()
{
   return 42;
}

-----------------------------------------------------------

and for bc.:


#include <stdio.h>
//#include <dlfcn.h>



double cos(double d)
{

	printf("f1 returns->%e\n",f1());

	return d;
}

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-08-31 15:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 22:43 export symbols Alberich de megres
2009-04-24  3:43 ` Ian Lance Taylor
2009-04-25 21:15   ` Andi Hellmund
2009-07-28 19:31     ` Alberich de megres
2009-08-02 15:03       ` Alberich de megres
2009-08-11 16:16       ` Ian Lance Taylor
     [not found]         ` <530d01580908120358o7dcb0315ue18e55a88b4a14e9@mail.gmail.com>
2009-08-12 15:08           ` Ian Lance Taylor
2009-08-14 11:37             ` Alberich de megres
2009-08-14 12:02               ` Andrew Haley
2009-08-16 15:15                 ` Alberich de megres
2009-08-17 16:24                   ` Andrew Haley
2009-08-31 23:02                     ` Alberich de megres

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).