Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - a error of Shared Library ,help ! help ! help ! : Page 1 of 2 (2 Items)
   
a error of Shared Library ,help ! help ! help !  
 Now, I have create a executble application and a Shared Library , But when I use the library  I receive a error msg as 

follows:
ldd:FATAL: Could not load library liblibrarytest1_g.so.1

note: The  error  occurs  when I add the Extral  Library for the executble application . but if I don't  add the Extral 

Libray , I  will  receive another error  msg  as  follows:
Shared library is corrupted

my code list:

executble application:

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <dlfcn.h>

void *FunctionLib;
const char *dlError;
int (*Function)();

int main(int argc, char *argv[]) {
	int   rc;             /*  return codes            */
	char HelloMessage[] = "Hello World\n";

	//printf("Welcome to the QNX Momentics IDE\n");
	FunctionLib=dlopen("/home/liblibrarytest1.so",RTLD_LAZY);
	dlError=dlerror();
	printf("  dlTest  3-Open Library with absolute path return-%s- \n", dlError);

	if (dlError) exit(1);
	printf("  dlTest  2-Original message \n");
	Function=dlsym(FunctionLib,"printUPPERCASE");
	dlError=dlerror();
	printf("  dlTest  4-Find symbol printUPPERCASE return-%s- \n", dlError);
	if (dlError) exit(1);
	rc = (*Function)( HelloMessage );
	printf("  dlTest  5-printUPPERCASE return-%s- \n", dlError);
	rc = dlclose(FunctionLib);
	dlError=dlerror();
	printf("  dlTest  7-Open Library with relative path return-%s- \n", dlError);
	return EXIT_SUCCESS;
}

Shared Library:

  #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int printUPPERCASE ( inLine )
char inLine[];
{
   char UPstring[256];
   char *inptr, *outptr;

   inptr = inLine;
   outptr = UPstring;
   while ( *inptr != '\0' )
      *outptr++ = toupper(*inptr++);
  *outptr++ = '\0';
   printf(UPstring);
   return(1);
}

note :  I  have compile and link success with the two project.