 |
 |
How do I add an include dir for C programs?
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
I'd like to include the readline library which is located in my '/sw/include/' folder. When I try to compile this program that uses it, it gives me errors because it cannot find <readline/readline.h>. How do I fix this?
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
You don't say how you're compiling it, but generally for autotools based projects you need to add "-I /sw/include" to the CFLAGS (and "-L /sw/lib" to the LDFLAGS).
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Originally posted by Angus_D:
You don't say how you're compiling it, but generally for autotools based projects you need to add "-I /sw/include" to the CFLAGS (and "-L /sw/lib" to the LDFLAGS).
I'm using 'cc' for to compile it. Using 'cc -I /sw/include -L /sw/lib fileman.c' gives me the following errors:
Code:
fileman.c: In function `dupstr':
fileman.c:61: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
fileman.c:62: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
fileman.c: In function `fileman_completion':
fileman.c:215: warning: assignment makes pointer from integer without a cast
ld: -L: directory name missing
I didn't write the program, but I'd assume it's supposed to work since it came from the readline info page. As you can see, at the end it's giving me an error relating to the -L option. Is the command simply wrong? Or is this a source problem?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I don't think there's supposed to be a space between the flags and their arguments (i.e. it should be -L/path/to/directory).
EDIT: Okay, apparently my memory fails me.
(Last edited by Chuckit; Aug 8, 2004 at 07:35 PM.
)
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Originally posted by Chuckit:
I don't think there's supposed to be a space between the flags and their arguments (i.e. it should be -L/path/to/directory).
That gives me even more errors:
Code:
fileman.c: In function `dupstr':
fileman.c:61: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
fileman.c:62: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
fileman.c: In function `fileman_completion':
fileman.c:215: warning: assignment makes pointer from integer without a cast
ld: Undefined symbols:
_add_history
_completion_matches
_readline
_rl_attempted_completion_function
_rl_readline_name
_xmalloc
Oh well, perhaps it's a bug in the code... though that doesn't make any sense since it's in the man page of readline...
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2001
Location: San Jose CA
Status:
Offline
|
|
Hi,
You need to tell cc that it needs to link with readline. Try adding '-lreadline' to the end of your command line.
--ranga
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Originally posted by ranga:
Hi,
You need to tell cc that it needs to link with readline. Try adding '-lreadline' to the end of your command line.
--ranga
I'm using the command 'cc -I/sw/include -I/sw/include/readline -L/sw/lib -Ireadline fileman.c'
and am still getting the same errors:
Code:
fileman.c: In function `dupstr':
fileman.c:61: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
fileman.c:62: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
fileman.c: In function `fileman_completion':
fileman.c:215: warning: assignment makes pointer from integer without a cast
ld: Undefined symbols:
_add_history
_completion_matches
_readline
_rl_attempted_completion_function
_rl_readline_name
_xmalloc
I tired variations for the command (taking out certain parts, adding others, etc) but all give me errors.
If you want to take a look at the source file, you can find it here.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally posted by itistoday:
I'm using the command 'cc -I/sw/include -I/sw/include/readline -L/sw/lib -Ireadline fileman.c'
You've misread. You are using the command cc -I/sw/include -I/sw/include/readline -L/sw/lib -Ireadline fileman.c. He said to use the command cc -I/sw/include -I/sw/include/readline -L/sw/lib -lreadline fileman.c. Lowercase L.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Status:
Offline
|
|
Originally posted by Chuckit:
You've misread. You are using the command cc -I/sw/include -I/sw/include/readline -L/sw/lib -Ireadline fileman.c. He said to use the command cc -I/sw/include -I/sw/include/readline -L/sw/lib -lreadline fileman.c. Lowercase L.
Haha! Man, we really should be putting these things in code tags shouldn't we  Damn font... can't tell the difference.
Thanks everyone for your help! It compiles fine now.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|