LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Error when building (http://www.linuxquestions.org/questions/linux-software-2/error-when-building-489057/)

Diomedes 10-03-2006 12:31 PM

Error when building
 
I am using Ubuntu 6.06, and am trying to install some new software. For example, one program I am trying to install is Baduki, a Go program. I untarred the tar.gz into /usr/local/src, cd'd to the new directory and entered ./configure. Everything configured smoothly, but when I try to 'make' it gives me a series of identical errors reading "patternsdat.h:400: error: initializer-string for array of chars is too long". After this it halts the make, and I can go no further. It pretty much does this when I try to make any piece of software. It is rather frustrating. I dunno if it makes a difference, but I had to apt-get the basic compiler packs (can't remember the pkg name at the moment) before I could even attempt this, as Ubuntu does not seem to come with gcc or anything of the sort.
Anyway, I would very much appreciate any help.

Thanks in advance,
Diomedes

KenJackson 10-03-2006 02:14 PM

Look for a file named patternsdat.h and look at line 400.

It's a little odd that something would be initialized in a header file in C (though C++ developers don't seem to mind), but hopefully you will see something like this:

char variable[4] = "abcd";

I think that would compile with no error with compiler gcc 2.9x. But recent versions of gcc have gotten very good at catching all manner of even insignificant errors.

If it is something as simple as my example, you can just change the 4 to a 5. But it's probably not that simple.

You could post it here and ask for comments. There may be a switch you can put in an environment variable and pass to configure or make to ignore the error. If you are desparate, you could see if there is an older version of gcc available.

Diomedes 10-03-2006 10:38 PM

Thanks for the response. I checked out line 400 (I am familiar with C to an extent, but it has been a while) and expected to find something simple. But as it turns out, line 400 is the final line in the file, containing only "};". At the top of the document there was a comment saying it was generated automatically by ./patterns.h, so I think I will check that out.

Diomedes 10-03-2006 10:50 PM

Grr... nothing yet. I looked into patterns.h, and the only char I found was pat[MAX_PATTERN_SIZE]. MAX_PATTERN_SIZE is defined in the first line of this excerpt.

Code:

...
#define MAX_PATTERN_SIZE        36        /* x_size * y_size */

#define PT_WHOLE        (1 << 0)
#define PT_CENTER        (1 << 1)
#define PT_SIDE                (1 << 2)
#define PT_CORNER        (1 << 3)
#define PT_IGNORE_D1        (1 << 4)
#define PT_IGNORE_D2        (1 << 5)
#define PT_IGNORE_D3        (1 << 6)
#define PT_IGNORE_D4        (1 << 7)
#define PT_IGNORE_D5        (1 << 8)
#define PT_IGNORE_D6        (1 << 9)
#define PT_IGNORE_D7        (1 << 10)

#define P_IGNORE_D        3

struct pattern_type {
  int id;
  int type;
  int x_size;
  int y_size;
  int x_pos;
  int y_pos;
  float value;
  char pat[MAX_PATTERN_SIZE];
};

Do you think perhaps there is a problem with defining the variable indirectly like that? I tried replacing pat[MAX_PATTERN_SIZE] with pat[36] and just getting rid of the line defining MAX_PATTERN_SIZE, but it gave me the same error messages when I tried to build it again. Any ideas?

KenJackson 10-03-2006 11:13 PM

Replacing MAX_PATTERN_SIZE with 36 wouldn't make any difference, but you might try 37.

Of course that could break something if the author made the assumption that the length would be 36, but it's worth a try.

There is probably an initializer somewhere something like this:
Code:

struct pattern_type pt = { 1,1,6,6,1,1,1.5, "abcdefghijklmnopqrstuvwxyz0123456789" };
In this example, there are exactly 36 characters in the array of 36 characters. But that leaves no room for the terminating NUL character that the compiler automatically adds to strings. Increasing the array size to 37 would give the needed space.

Diomedes 10-04-2006 01:18 AM

It worked! Thank you very much. I will keep this solution in mind for future reference.


All times are GMT -5. The time now is 08:57 PM.