Menu
Sites
Language

How to make shared libary and link it

This description is for making shared library and for linking it in project. Right-lick shared library project in project explorer and change architecture to ARMv7-a Properties --> C/C++ Build --> Tizen settings --> architecture
//--mysharedLib project--

//mysharedlib.h
  EXPORT_API int mytemp(int);

//mysharedlib.c
  int mytemp(int value) {
		return value+1024;
}




//--mysharedlisttest project--
// you need to add "mysharedlib" into Properties-->C/C++ Build -->Settings -->C++ Linker -->Libraries -->Libraraies(-l)
// and you need select "libsharedlib.so" into Properties -->C/C++ Build -->Settings --> C++ Linker --> Library search path(-L)

//mysharedlisttest.h
 extern  int mytemp(int);
 
 //mysharedlisttest.c
 void  sharedlibarytest() {

	int i=100;
	int ret;
	ret =  mytemp(i);
	dlog_print(DLOG_INFO, LOG_TAG, " %d", ret);
}

Responses

1 Replies
Anand Rudrakshi

Please mention to add the below code in header files so that the library could be used by both c and c++ applications.

#ifdef __cplusplus
extern "C" {  // only need to export C interface if used by C++ source code
#endif

//Exported api

EXPORT_API int mytemp(int);

#ifdef __cplusplus
}
#endif