The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file access log jorgelopez100 UNIX for Dummies Questions & Answers 2 07-18-2008 12:09 PM
[C++] File I/O (Reading from a Random-Access File) VersEtreOuNe High Level Programming 0 02-12-2008 04:34 PM
HOw I can Know who Access my file!! geoquest UNIX for Dummies Questions & Answers 3 06-19-2002 06:10 PM
access file for sendmail liyas UNIX for Dummies Questions & Answers 3 10-11-2001 10:10 PM
Need help to access/mount so to access folder/files on a Remote System using Linux OS S.Vishwanath UNIX for Dummies Questions & Answers 2 07-30-2001 08:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2008
amitp amitp is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
access .so file in C and C++

Hi All,
I created a simple .so file in C program on Linux and accessed it from another C program; I was successful but when I tried to access the same .so file from C++ program it gave me error " undefined reference".

Now in new project I created another .so file in C++ program and accessed it from another CPP program; I was successful but when I tried to access same .so file from C program it gave me error "undefined reference "

What am I supposed to do If I want to access a C program .so file from CPP program or vice versa. Any hints

Thanks in advance..
  #2 (permalink)  
Old 08-23-2008
p50p100 p50p100 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 21
You should add extern to header file.

Code:
#if defined(__cplusplus)
extern "C"
{
#endif
    //ptototype declare
    char *yourfunction(void);

#if defined(__cplusplus)
}
#endif
If you want to know the reason why it needs,
please compare with results of below command with and without above description.
Code:
readelf -sD libYourlib.so | grep "FUNC *GLOBAL"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0