export symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux