![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 08:16 AM |
| error during run: St9bad_alloc - Getting this error while using some conversion progr | sathu_pec | Shell Programming and Scripting | 1 | 01-20-2008 11:38 PM |
| I got error like...syntax error on line 1, teletype | koti_rama | UNIX for Advanced & Expert Users | 2 | 07-07-2007 04:35 PM |
| error reading sections error at install | doelman | SUN Solaris | 2 | 02-05-2007 09:21 AM |
| Error: Internal system error: Unable to initialize standard output file | firkus | UNIX for Dummies Questions & Answers | 2 | 10-25-2005 12:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
|||
|
|||
|
Comment out this line:
Code:
extern char *strerror(int errno); Code:
// Near top util.h #include <string.h> // Lower down #ifndef strerror extern char *strerror(int errno); #endif/*strerror*/ Code:
// Start of file #ifndef __STRING_H__ #define __STRING_H__ // file contents ... #endif/*__STRING_H__*/ |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
strerror() is declared in string.h according to ISO
It's strange that this code worked earlier |
|
#10
|
|||
|
|||
|
Dear Corona
If I comment out this what I will get in error couliba@linux:~/bin/GaSource> make find_rules cc find_rules.c -o find_rules /tmp/ccsfOXjS.o(.text+0x72): In function `main': find_rules.c: undefined reference to `seed' /tmp/ccsfOXjS.o(.text+0x18e):find_rules.c: undefined reference to `print_help_message' /tmp/ccsfOXjS.o(.text+0x23d):find_rules.c: undefined reference to `read_cline' /tmp/ccsfOXjS.o(.text+0x679):find_rules.c: undefined reference to `define_type' /tmp/ccsfOXjS.o(.text+0x68c):find_rules.c: undefined reference to `define_type' /tmp/ccsfOXjS.o(.text+0x69f):find_rules.c: undefined reference to `define_type' /tmp/ccsfOXjS.o(.text+0x6e5):find_rules.c: undefined reference to `define_function' /tmp/ccsfOXjS.o(.text+0x702):find_rules.c: undefined reference to `define_tree' /tmp/ccsfOXjS.o(.text+0x789):find_rules.c: undefined reference to `init_data' /tmp/ccsfOXjS.o(.text+0x821):find_rules.c: undefined reference to `read_data' /tmp/ccsfOXjS.o(.text+0x850):find_rules.c: undefined reference to `normalize_price' /tmp/ccsfOXjS.o(.text+0xe30):find_rules.c: undefined reference to `compounded_return' /tmp/ccsfOXjS.o(.text+0xe61):find_rules.c: undefined reference to `compounded_return' /tmp/ccsfOXjS.o(.text+0xf30):find_rules.c: undefined reference to `new_tree' /tmp/ccsfOXjS.o(.text+0x10fa):find_rules.c: undefined reference to `create_population' /tmp/ccsfOXjS.o(.text+0x1151):find_rules.c: undefined reference to `create_offspring' /tmp/ccsfOXjS.o(.text+0x11da):find_rules.c: undefined reference to `eval_genome' /tmp/ccsfOXjS.o(.text+0x1210):find_rules.c: undefined reference to `compute_return' /tmp/ccsfOXjS.o(.text+0x123f):find_rules.c: undefined reference to `compounded_return' /tmp/ccsfOXjS.o(.text+0x12a1):find_rules.c: undefined reference to `compute_statistics' /tmp/ccsfOXjS.o(.text+0x12b8):find_rules.c: undefined reference to `cluster_population' /tmp/ccsfOXjS.o(.text+0x14cf):find_rules.c: undefined reference to `eval_genome' /tmp/ccsfOXjS.o(.text+0x1505):find_rules.c: undefined reference to `compute_return' /tmp/ccsfOXjS.o(.text+0x1534):find_rules.c: undefined reference to `compounded_return' /tmp/ccsfOXjS.o(.text+0x17ce):find_rules.c: undefined reference to `copy_genome' /tmp/ccsfOXjS.o(.text+0x1b79):find_rules.c: undefined reference to `save_genome' /tmp/ccsfOXjS.o(.text+0x1c24):find_rules.c: undefined reference to `eval_genome' /tmp/ccsfOXjS.o(.text+0x1c5e):find_rules.c: undefined reference to `compute_return' /tmp/ccsfOXjS.o(.text+0x1c91):find_rules.c: undefined reference to `compounded_return' /tmp/ccsfOXjS.o(.text+0x1d9f):find_rules.c: undefined reference to `dispose_population' /tmp/ccsfOXjS.o(.text+0x1de3):find_rules.c: undefined reference to `descending_order' /tmp/ccsfOXjS.o(.text+0x1dfc):find_rules.c: undefined reference to `order_by_key' /tmp/ccsfOXjS.o(.data+0x50): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x54): undefined reference to `eval_if_then' /tmp/ccsfOXjS.o(.data+0xa0): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0xa4): undefined reference to `eval_if_then_else' /tmp/ccsfOXjS.o(.data+0xf0): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0xf4): undefined reference to `eval_and' /tmp/ccsfOXjS.o(.data+0x140): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x144): undefined reference to `eval_or' /tmp/ccsfOXjS.o(.data+0x190): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x194): undefined reference to `eval_not' /tmp/ccsfOXjS.o(.data+0x1e0): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x1e4): undefined reference to `eval_greater' /tmp/ccsfOXjS.o(.data+0x230): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x234): undefined reference to `eval_less' /tmp/ccsfOXjS.o(.data+0x278): undefined reference to `init_boolean' /tmp/ccsfOXjS.o(.data+0x27c): undefined reference to `read_boolean' /tmp/ccsfOXjS.o(.data+0x280): undefined reference to `print_boolean' /tmp/ccsfOXjS.o(.data+0x2d4): undefined reference to `eval_flip' /tmp/ccsfOXjS.o(.data+0x320): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x324): undefined reference to `eval_plus' /tmp/ccsfOXjS.o(.data+0x370): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x374): undefined reference to `eval_minus' /tmp/ccsfOXjS.o(.data+0x3c0): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x3c4): undefined reference to `eval_multiply' /tmp/ccsfOXjS.o(.data+0x410): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x414): undefined reference to `eval_divide' /tmp/ccsfOXjS.o(.data+0x460): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x464): undefined reference to `eval_negation' /tmp/ccsfOXjS.o(.data+0x4b0): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x4b4): undefined reference to `eval_norm' /tmp/ccsfOXjS.o(.data+0x500): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x504): undefined reference to `eval_average' /tmp/ccsfOXjS.o(.data+0x550): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x554): undefined reference to `eval_maximum' /tmp/ccsfOXjS.o(.data+0x5a0): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x5a4): undefined reference to `eval_minimum' /tmp/ccsfOXjS.o(.data+0x5f0): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x5f4): undefined reference to `eval_slope' /tmp/ccsfOXjS.o(.data+0x640): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x644): undefined reference to `eval_volatility' /tmp/ccsfOXjS.o(.data+0x690): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x694): undefined reference to `eval_lag' /tmp/ccsfOXjS.o(.data+0x6e0): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x6e4): undefined reference to `eval_data' /tmp/ccsfOXjS.o(.data+0x728): undefined reference to `init_real' /tmp/ccsfOXjS.o(.data+0x72c): undefined reference to `read_real' /tmp/ccsfOXjS.o(.data+0x730): undefined reference to `print_real' /tmp/ccsfOXjS.o(.data+0x784): undefined reference to `eval_price' /tmp/ccsfOXjS.o(.data+0x7d4): undefined reference to `eval_compounded' collect2: ld returned 1 exit status make: *** [find_rules] Error 1 and If add the code as the below /*------------------------------------------------------------------------------ File: util.h Date: January 26, 1992 Copyright (c) Risto Karjalainen. All rights reserved. Utility functions of general use. ------------------------------------------------------------------------------*/ #inlcude <string.h> #define max(x,y) ((x) > (y) ? (x) : (y)) #define min(x,y) ((x) < (y) ? (x) : (y)) #ifndef strerror extern char *strerror(int errno); #endif /*------------------------------------------------------------------------------ 'get_boolean' prints '*prompt' and reads a character from stdin. 'answers' contains the valid character set. If the entered character equals 'affirm', 'def' is returned. ------------------------------------------------------------------------------*/ extern int get_boolean(char *prompt, char *answers, int def, char affirm); /*------------------------------------------------------------------------------ 'get_int' prints '*prompt' and reads an integer from stdin. The entered integer must be in the range 'min' .. 'max'. If none is entered, 'def' is returned, instead. */ I will receive this error ouliba@linux:~/bin/GaSource> make find_rules cc find_rules.c -o find_rules In file included from find_rules.c:19: util.h:17: error: conflicting types for `strerror' /usr/include/string.h:256: error: previous declaration of `strerror' find_rules.c: In function `main': find_rules.c:203: warning: passing arg 1 of `strerror' makes pointer from integer without a cast find_rules.c:248: warning: passing arg 1 of `strerror' makes pointer from integer without a cast find_rules.c:315: warning: passing arg 1 of `strerror' makes pointer from integer without a cast make: *** [find_rules] Error 1 couliba@linux:~/bin/GaSource> Any more advise, I appreciate so much Quote:
|
|
#11
|
|||
|
|||
|
That error is what Corona is trying to help you with - you have strerror declared in util.h. Put the #ifndef and #define statement he gave you around the place where you encounter the error in util.h.
To find where strerror is doubly defined try this: Code:
gcc -E find_rules.c | grep 'strerror' |
|
#12
|
|||
|
|||
|
Those errors are exactly what it says they are. It cannot find those functions. You probably need to compile another file to get them. Not all C files are standalone. The general sequence is:
Code:
cc -c file1.c -o file1.o cc -c file2.c -o file2.o ... cc -c file5.c -o file5.o cc file1.o file2.o file3.o file4.o file5.o -o program Code:
OBJS=file1.o file2.o file3.o file4.o file5.o
program:$(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o $@
And please, for the love of yog, put your code in code-tags!! Last edited by Corona688; 07-07-2006 at 07:26 AM. |
|
#13
|
|||
|
|||
|
Quote:
As you said. it can not find those function. that is right but how do I make it to find those function. Thank you very much |
|
#14
|
|||
|
|||
|
This might best be shown by example.
In a directory by itself, create this file: Code:
// main.c
#include <stdio.h>
int main(int argc, char *argv[])
{
int n;
fprintf(stderr,"main(%d,[",argc);
for(n=0; n<argc; n++)
fprintf(stderr," '%s'",argv[n]);
fprintf(stderr," ]);\n");
return(0);
}
Code:
# gcc main.c -o main # ./main main(1,[ './main' ]); # Code:
# gcc -c main.c -o main.o # gcc main.o -o main # ./main main(1,[ './main' ]); # Now let's try and use a function from another .c file. First, create this file: Code:
// library.c
#include <stdio.h>
int library_function(int c)
{
fprintf(stderr,"library_function(%d)\n",c);
return(c-3);
}
Code:
#include <stdio.h>
extern int library_function(int c);
int main(int argc, char *argv[])
{
int n;
fprintf(stderr,"main(%d,[",argc);
for(n=0; n<argc; n++)
fprintf(stderr," '%s'",argv[n]);
fprintf(stderr," ]);\n");
printf("library_function(%d) returns %d\n",32,library_function(32));
return(0);
}
Code:
# gcc -c main.c -o main.o # gcc main.o -o main main.o: In function `main': main.c:(.text+0x86): undefined reference to `library_function' collect2: ld returned 1 exit status # Code:
# gcc -c main.c -o main.o # gcc -c library.c -o library.o # gcc main.o library.o -o main # ./main main(1,[ './main' ]); library_function(32) library_function(32) returns 29 # Now, if you want your makefile to do that, you need to tell it that the output file needs main.o and library.o. Here's a simple makefile: Code:
main:main.o library.o
$(CC) main.o library.o $(LDFLAGS) -o $@
clean:
rm -f main main.o library.o
Code:
# make clean rm -f main main.o library.o # make main cc -c -o main.o main.c cc -c -o library.o library.c cc main.o library.o -o main # ./main main(1,[ './main' ]); library_function(32) library_function(32) returns 29 # So there you go. You'll need to find the .c file that these missing functions reside in, convert it to an object, then link it into your executable. Last edited by Corona688; 07-11-2006 at 07:25 AM. Reason: mistake in examples |
|||
| Google The UNIX and Linux Forums |