- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- aCC giving compilation errors saying getmntent_r ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2008 04:31 AM
05-06-2008 04:31 AM
I have used the getmntent_r() function for my application in in linux. I am trying to port the same to hpux 11iv2. I confiromed the availability of "getmntent_r" by looking at man and header file "mntent.h".
When i am trying to compile this program with aCC as follows it is giving compilation errors.
can you please let me know how can get rid of these and make it working on hpux.
Program and commands used :-
-------------------------------
attempt 1:-
----------
# aCC trail2.cpp
"trail2.cpp", line 11: error #2020: identifier "getmntent_r" is undefined
getmntent_r(fp,&s,buf,4096);
^
1 error detected in the compilation of "trail2.cpp".
attempt2,3,4:-
-----------
# aCC trail2.cpp /usr/lib/libd4r.sl
"trail2.cpp", line 11: error #2020: identifier "getmntent_r" is undefined
getmntent_r(fp,&s,buf,4096);
^
1 error detected in the compilation of "trail2.cpp".
# aCC -ld4r trail2.cpp
"trail2.cpp", line 11: error #2020: identifier "getmntent_r" is undefined
getmntent_r(fp,&s,buf,4096);
^
1 error detected in the compilation of "trail2.cpp".
# aCC -L/usr/lib trail2.cpp
"trail2.cpp", line 11: error #2020: identifier "getmntent_r" is undefined
getmntent_r(fp,&s,buf,4096);
^
1 error detected in the compilation of "trail2.cpp".
# aCC -L/usr/lib -ld4r trail2.cpp
"trail2.cpp", line 11: error #2020: identifier "getmntent_r" is undefined
getmntent_r(fp,&s,buf,4096);
^
1 error detected in the compilation of "trail2.cpp".
#
Program:-(trail2.cpp)
---------------------
#include
#include
//#define _PTHREADS_DRAFT4
int main()
{
FILE *fp;
char *buf;
struct mntent s;
getmntent_r(fp,&s,buf,4096);
//getmntent_r();
printf(" %d ", sizeof(buf));
return 0;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2008 05:31 AM
05-06-2008 05:31 AM
Re: aCC giving compilation errors saying getmntent_r is undefined
/usr/include/mntent.h shows:
[...]
#ifdef _PTHREADS_DRAFT4
extern int getmntent_r(FILE *, struct mntent *, char *, int);
[...]
So, I'd guess that you need to get
_PTHREADS_DRAFT4 defined if you expect to get
getmntent_r() declared. I assume that there
are right and wrong ways to do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2008 08:11 PM
05-06-2008 08:11 PM
Re: aCC giving compilation errors saying getmntent_r is undefined
I have tried in these ways also
(1) aCC -D_PTHREADS_DRAFT4 trail2.cpp
(2) with #define _PTHREADS_DRAFT4 in the program trail2.cpp
But none of those ways worked. Can you please let me know how differently can i try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2008 09:44 PM
05-06-2008 09:44 PM
Re: aCC giving compilation errors saying getmntent_r is undefined
> ways.
Not really. Remember:
> I know nothing, [...]
Perhaps defining _PTHREADS_DRAFT4 is the
right way. Perhaps there's some compiler
option about which I know nothing. One sure
thing is that "#define _PTHREADS_DRAFT4"
_after_ "#include
to do much for you.
> But none of those ways worked
"Doesn't work" is not a good problem
description. Defining _PTHREADS_DRAFT4
clears the "error #2020", but it doesn't
solve all the problems in your code. As
usual, actual error messages might be more
useful than vague descriptions.
It's a long way from useful, but you might
try starting with something like this:
td192> cat trail2a.cpp
#define _PTHREADS_DRAFT4
#include
#include
#include
int main()
{
FILE *fp;
char buf[ 4096];
struct mntent s;
int sts;
fp = setmntent(MNT_MNTTAB, "r+");
sts = getmntent_r(fp,&s,buf,4096);
printf( " sts = %d, errno = %d.\n", sts, errno);
if (sts < 0)
{
printf( " %s\n", strerror( errno));
}
else
{
printf( " %s\n", s.mnt_fsname);
}
return 0;
}
td192> aCC -o trail2a -lc_r trail2a.cpp
td192> ./trail2a
sts = -1, errno = 13.
Permission denied
On a system where I have higher status but
only GCC:
dy # g++ -o trail2a -lc_r trail2a.cpp
dy # ./trail2a
sts = 0, errno = 0.
/dev/vg00/lvol3
(Of course, calling this code C++ instead of
C is a little grandiose.)
Finding the run-time library which had
_getmntent_r in it was more trouble than it
should have been, I thought. Perhaps "man
pthread" says something useful. Also, these
tests were done on 11.11 systems. Things
could be different on 11.23, and IA64 may
be different from PA-RISC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2008 04:00 AM
05-07-2008 04:00 AM
SolutionThe header file and man page are broken. You should NOT be using this obsolete function.
It doesn't exist on IPF, and was probably there for 10.x for libcma? It does seem to be in libd4r.sl for PA?
You should use getmntent(3) instead, since it is threadsafe.
>Steven: I'd guess that you need to get
_PTHREADS_DRAFT4 defined if you expect to get
getmntent_r() declared.
Don't even think about defining obsolete _PTHREADS_DRAFT4. This was for libcma.
>Finding the run-time library which had
_getmntent_r in it was more trouble than it
should have been
Just use:
$ nm -pxNA /usr/lib/hpux32/lib* | fgrep getmntent_r
You'll find it isn't in any libs on IPF.