Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RedHat 6.2 : C Program getdents ld error

Posted on 2001-06-27
1
Medium Priority
?
429 Views
Last Modified: 2007-12-19
Hi!
I am recieving an ld error when compiling a simple C program using the "getdents" function. I'm hoping that one of the experts out there can decode & fix the following ld error:
/tmp/ccO4jRVF.o: In function `main':
/tmp/ccO4jRVF.o(.text+0x50): undefined reference to `getdents'
collect2: ld returned 1 exit status

Here is a copy of my program:
/**********************************
 * Program Name : getdents_tester.c
 * Created      : LL 06/05/01
 **********************************/

#include <stdio.h>
#include <unistd.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/unistd.h>

struct dirent *dirent_p;
unsigned      int fd;
unsigned      int count;
int           rc;

main()
{
   fd = 0x01;
   count = 0x200;
   printf("fd = 0x%x, count = 0x%x\n",fd,count);
   printf("Calling getdents...\n");
   rc = getdents(fd,dirent_p,count);
   printf("getdents returned 0x%x\n",rc);
   return(rc);
}

Good Luck!
Thanks!
lori-Ann :-)
0
Comment
Question by:lleahy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
bryanh earned 200 total points
ID: 6249509
First of all, did you compile cleanly with gcc -Wall?  In particular, it's important to know you don't have any implicitly defined functions.  Using gcc -Wall all the time can save you a lot of pain.

In this case, I believe you'll find that getdents() is not a GNU C library function, so you can't use it like this.  (The fact that you have to include <linux/...> files, which are Linux kernel interfaces, also tells you this).  You can use the _syscall3() C library function as described in the getdents() Linux man page, or you can use the POSIX function for reading directories, readdir().  readdir() uses the getdents() kernel service to do its job.  Not to be confused with the readdir() system call, which is a kernel service that the readdir() C library function used to use and still exists for backward compatibility.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question