Make sure that your C compiler can compile programs from the command-line. I've had a few installations of Dev-C++ which worked fine from the IDE but wouldn't work from the command-line. And the configure script, of course, would be using the command line.
A few things that might go wrong:
- The compiler's bin directory might not be in the PATH. You'll get "bad command or file name" or the equivalent when typing "gcc" if this is the case.
- The compiler may not be able to find its include path. This has happened to me before. Usually the compiler works fine if you run it from its bin directory (as the IDE does), but not when you run it from elsewhere; even if the executable is in the PATH. See below. [1]
- The compiler may not be able to find the libraries. This might happen if you put libraries in a subdirectory of the compiler's lib directory, for example. You can add -L flags to get the compiler to look in other places for libraries.
[edit] You should look at the configure log file (is it config.log?). That will tell you the compiler errors that resulted in the script deciding that your compiler can't produce executables. [/edit]
[1] I solved this somehow, but unfortunately I can't remember how. So I'll just post the simple program I wrote to "fix" this. It can be run anywhere, but executes gcc from its install directory. It changes relative pathnames into absolute ones, so that the paths will be valid from gcc's bin directory.
Yes, it would probably be easier to figure out which directories gcc can't find and add them to the -I command. Or it would be better yet if I could remember how I ultimately fixed this, but unfortunately I can't. Sorry.
Code:
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <unistd.h>
#define ECHO 0
struct string_t {
char *data;
size_t len, alen;
};
void print_usage(const char *progname);
void append_dir_sep(char **path, size_t *len);
void append_argument(struct string_t *string, const char *str, size_t slen);
char *start_path(char *filename);
int is_file(const char *filename);
int main(int argc, char *argv[]) {
char *cwd = getcwd(0, BUFSIZ);
size_t cwdlen = strlen(cwd);
char *end;
int x, is;
struct string_t command = {0, 0, 0};
if(argc < 2) {
print_usage(argv[0]);
return 1;
}
append_dir_sep(&cwd, &cwdlen);
end = start_path(argv[1]);
if(end != argv[1]) *end++ = 0;
append_argument(&command, end, strlen(end));
for(x = 2; x < argc; x ++) {
is = is_file(argv[x]);
append_argument(&command, " ", 1);
if(is) {
append_argument(&command, cwd, cwdlen);
}
append_argument(&command, argv[x], strlen(argv[x]));
}
if(end != argv[1]) {
#if ECHO
printf("chdir \"%s\" ; ", argv[1]);
#endif
chdir(argv[1]);
}
#if ECHO
puts(command.data);
#endif
system(command.data);
free(command.data);
chdir(cwd);
free(cwd);
return 0;
}
void print_usage(const char *progname) {
fprintf(stderr, "\nexecgcc by DWK"
"\nExecutable path: %s\n"
"\nusage: execgcc program [[--file] argN]\n"
"\nChanges to the directory that program is located in, prepending"
"the current directory to arguments that are existing files or that"
" have the --file flag before them.\n", progname);
}
void append_dir_sep(char **path, size_t *len) {
char *p;
for(p = *path; *p; p ++) {
if(*p == '\\') *p = '/';
}
if(*len && (*path)[*len-1] != '\\' && (*path)[*len-1] != '/') {
p = realloc(*path, *len + 2);
if(!p) {
fprintf(stderr, "Out of memory\n");
free(*path);
exit(1);
}
*path = p;
(*path)[(*len)++] = '/';
(*path)[*len] = 0;
}
}
void append_argument(struct string_t *string, const char *str, size_t slen) {
char *p;
size_t newlen = string->len + slen;
if(newlen + 1 >= string->alen) {
if(!string->alen) string->alen = 1;
while(newlen + 1 >= string->alen) {
string->alen *= 2;
}
p = realloc(string->data, string->alen);
if(!p) {
free(string->data);
fprintf(stderr, "execgcc: Out of memory\n");
exit(1);
}
string->data = p;
}
strcpy(string->data + string->len, str);
string->len += slen;
}
char *start_path(char *filename) {
char *p = strrchr(filename, '\\');
if(!p) p = filename;
return p;
}
int is_file(const char *filename) {
if(isalpha(*filename) && filename[1] == ':') return 0;
return *filename != '-' && *filename != '/' && *filename != '\\';
}
I would use this program like this. (Z:\ is the Windows drive from wine.)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void grow_command(char **command, size_t *len, size_t need);
void add_string(const char *str, char **command, size_t *len,
size_t *used);
int main(int argc, char *argv[]) {
char *command = 0;
size_t len = 0, used = 0;
int x;
add_string("Z:/home/dwk/bin/execgcc.exe"
" Z:/mnt/vista/Dev-Cpp/bin/gcc.exe",
&command, &len, &used);
for(x = 1; x < argc; x ++) {
add_string(" ", &command, &len, &used);
add_string(argv[x], &command, &len, &used);
}
/*puts(command);*/
system(command);
free(command);
return 0;
}
void grow_command(char **command, size_t *len, size_t need) {
if(*len > need) return;
if(!*len) *len = 1;
while(*len <= need) *len *= 2;
*command = realloc(*command, *len);
}
void add_string(const char *str, char **command, size_t *len,
size_t *used) {
grow_command(command, len, *used + 1 + strlen(str) + 1);
*used += sprintf(*command + *used, "%s", str);
}
Anyway, I'm not sure how helpful that will be, but it might do something at least. Good luck.