trying to compile and don't understand error message


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers trying to compile and don't understand error message
# 1  
Old 10-13-2011
trying to compile and don't understand error message

this is my program i am trying to compile
Code:
/* filedata -- display information about a file */

#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>

/*
* use octarray for determing
* if permission bits set
*/

static short octarray[9] = {0400, 0200, 0100, 0040, 0020, 0010, 0004, 0002, 0001};

/* mnemonic codes for file permissions,
* 10 chars long because of the terminating null
*/

static char perms[10] = "rwxrwxrwx";

int filedata(const char *pathname)
{
struct stat statbuf;
char descrip[10];

int j;

if(stat(pathname, &statbuf) == -1)
{
        fprintf(stderr, "Couldn't stat %s\n", pathname);
        return(-1);
}

/* put permissions into readable form */

for(j = 0; j < 9; j++)
{

 /*
        * test whether permission set
        * using bitwise AND
        */

        if(statbuf.st_mode & octarray[j])
                descrip[j] = perms[j];
        else
	descrip[j] = '-';
}

descrip[9] = '\0'; /* make sure we've got a string */

/* display file information */

printf("\nFile %s :\n", pathname);
printf("Size %ld bytes\n", statbuf.st_size);
printf("User-id %d, Group-id %d\n", statbuf.st_uid,
        statbuf.st_gid);
printf("Permissions: %s\n", descrip);
return(0);
}

and this is the error message I get

Code:
$ gcc filedatatest.c -o filedatatest
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
$

# 2  
Old 10-13-2011
# 3  
Old 10-13-2011
Yep as Alister mentioned 'Main Function' or lack of one ;-)

Steve
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I don't understand conditions :(

Hi there, I have a very general question. I'm rather new to (bash) shell scripting and I don't understand how conditions work... I've read numerous tutorials but I don't get it. I really don't. Sometime what I do works, sometime it doesn't and that's frustating. So what's the actual difference... (0 Replies)
Discussion started by: hypsis
0 Replies

2. Shell Programming and Scripting

Perl syntax that I don't understand.

I'm just trying to confirm that I understand someone's code correctly. If someone has code that says: $foo ||= mysub(); I'm assuming that it means if $foo is nothing or undef, then assign it some value via mysub(). If I'm wrong on this, please let me know. Also, what's the difference... (4 Replies)
Discussion started by: mrwatkin
4 Replies

3. UNIX for Dummies Questions & Answers

Another Simple BASH command I don't understand. Help?

I have a text file called file1 which contains the text: "ls -l" When I enter this command: bash < file1 > file1 file1 gets erased. However if I enter this command: bash < file1 > newfile the output from "ls -l" is stored in newfile. My question is why doesn't file1's text ("ls -l") get... (3 Replies)
Discussion started by: phunkypants
3 Replies

4. Homework & Coursework Questions

I don't understand some basics..

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1)find all lines in file ,myf that contain all the words cat dog and mouse in any order and start with the letter... (1 Reply)
Discussion started by: cudders
1 Replies

5. Shell Programming and Scripting

Don't understand how RS functions in awk

I learn using RS in awk to extract portion of file in this forum which is wonderful solution to the problem. However, I don't understand how exactly it operates. I don't quite understand the mechanism behind how searching for /DATA2/ can result in extracting the whole section under "DATA2" ... (3 Replies)
Discussion started by: joe228
3 Replies

6. Programming

aCC Compile error message

my C++ Compiler is ACC version aCC: HP ANSI C++ B3910B A.03.85 OS Version B.11.11 this my program error message I don't know what error it is aCC -g -DHPUX -DCHT_DEBUG -DNOSTD -c CProcess.cpp Error 181: "CProcess.cpp", line 83 # Expected 0 argument(s) for "void... (1 Reply)
Discussion started by: alert0919
1 Replies

7. UNIX for Advanced & Expert Users

don't understand the unix script

if {"$my_ext_type" = MAIN]; then cd $v_sc_dir Filex.SH $v_so_dir\/$v_fr_file Can somebody tell me what does this suggest. I am pretty new to unix and I am getting confused. What i understood from here is If we have a file extension name as MAIN which we have then we change the directory to... (1 Reply)
Discussion started by: pochaman
1 Replies

8. Programming

compile error message

i was trying to compile a c program and got the error below. i need help on how to resolve this $ make -ef putput `if ; then echo getinf.awk ; else echo getora.awk;fi` EI.sql `if ; then echo esql -static ; else echo esqlo8i;fi` -O -I. -c EI`if ; then echo .ec; else echo... (4 Replies)
Discussion started by: putput
4 Replies
Login or Register to Ask a Question