Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compile Error
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Jon Wilder
Tux's lil' helper
Tux's lil' helper


Joined: 04 Apr 2011
Posts: 98
Location: Fresno CA

PostPosted: Fri Jul 08, 2011 7:11 pm    Post subject: Compile Error Reply with quote

I'm trying to compile a program called Odyssey, which is a programmer program for PIC microcontrollers and I keep getting the following error messages -

Code:

wilderamplification odyssey-0.4 # ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ranlib... ranlib
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking new usability... yes
checking new presence... yes
checking for new... yes
checking exception usability... yes
checking exception presence... yes
checking for exception... yes
checking stdexcept usability... yes
checking stdexcept presence... yes
checking for stdexcept... yes
checking iterator usability... yes
checking iterator presence... yes
checking for iterator... yes
checking string usability... yes
checking string presence... yes
checking for string... yes
checking map usability... yes
checking map presence... yes
checking for map... yes
checking vector usability... yes
checking vector presence... yes
checking for vector... yes
checking for select... yes
checking for snprintf... yes
checking linux/parport.h usability... yes
checking linux/parport.h presence... yes
checking for linux/parport.h... yes
checking linux/ppdev.h usability... yes
checking linux/ppdev.h presence... yes
checking for linux/ppdev.h... yes
checking sys/io.h usability... yes
checking sys/io.h presence... yes
checking for sys/io.h... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating data/Makefile
config.status: creating src/config.h
config.status: src/config.h is unchanged
config.status: executing depfiles commands
wilderamplification odyssey-0.4 # make
Making all in src
make[1]: Entering directory `/home/jon/odyssey-0.4/src'
make  all-am
make[2]: Entering directory `/home/jon/odyssey-0.4/src'
depbase=`echo ConfigFile.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; \
if g++ -DHAVE_CONFIG_H  -I. -DDATADIR="\"/usr/local/share/odyssey\"" -DSYSCONFDIR="\"/usr/local/etc\""  -Wall -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror -g -O2 -MT ConfigFile.o -MD -MP -MF "$depbase.Tpo" -c -o ConfigFile.o ConfigFile.cxx; \
then mv -f "$depbase.Tpo" "$depbase.Po"; else rm -f "$depbase.Tpo"; exit 1; fi
ConfigFile.cxx: In constructor 'ConfigFile::ConfigFile(const char*, const char*, const char*)':
ConfigFile.cxx:34:23: error: 'getenv' was not declared in this scope
ConfigFile.cxx: In member function 'bool ConfigFile::get_integer(const std::string&, const std::string&, long int*)':
ConfigFile.cxx:189:38: error: 'strtol' was not declared in this scope
ConfigFile.cxx: In member function 'bool ConfigFile::get_integerv(const std::string&, const std::string&, long int*, unsigned int*)':
ConfigFile.cxx:235:52: error: 'strtol' was not declared in this scope
make[2]: *** [ConfigFile.o] Error 1
make[2]: Leaving directory `/home/jon/odyssey-0.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/jon/odyssey-0.4/src'
make: *** [all-recursive] Error 1


And here is the source from ConfigFile.cxx -

Code:

/* Copyright (C) 2002-2004  Mark Andrew Aikens <marka@desert.cx>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: ConfigFile.cxx,v 1.15 2006/04/29 14:14:30 marka Exp $
 */
using namespace std;

#include <stdio.h>
#include <string.h>
#include <stdexcept>
#include <new>
#include "ConfigFile.h"
#include "Util.h"


ConfigFile::ConfigFile(const char *usercfg, const char *progid, const char *syscfg) {
   const char *dir;
   int userfilenamelen;
   bool dot=false;

   dir = getenv("CONFIG");
   if(dir == NULL) {
      dot = true;
      dir = getenv("HOME");
      if(dir == NULL)
         dir = ".";
   }

   if(syscfg != NULL) {
      this->sysfilename = new char[strlen(syscfg)+2];
      if(this->sysfilename == NULL)
         throw bad_alloc();
      strcpy(this->sysfilename, syscfg);
   } else {
      this->sysfilename = NULL;
   }

   userfilenamelen = strlen(dir) + strlen(usercfg) + 4;
   if(progid != NULL) userfilenamelen += (strlen(progid) + 2);
   this->userfilename=new char[userfilenamelen];
   if(this->userfilename == NULL) throw bad_alloc();

   if(progid != NULL) {
      sprintf(this->userfilename, "%s/%s%s", dir, (dot ? "." : ""), progid);
      Util::mkdir_p(this->userfilename);
      sprintf(this->userfilename, "%s/%s%s/%s", dir, (dot ? "." : ""), progid, usercfg);
   } else {
      sprintf(this->userfilename, "%s/%s%s", dir, (dot ? "." : ""), usercfg);
   }
   reread();
}


ConfigFile::~ConfigFile(void) {
   /* I hope you already did a writeback if you wanted to save modifications */
   if(this->userfilename != NULL) delete this->userfilename;
   if(this->sysfilename != NULL) delete this->sysfilename;
}


bool ConfigFile::reread(void) {
   this->cache.clear();
   if(this->sysfilename != NULL) {
      bool a, b;
      a = read_configfile(this->sysfilename, this->cache);
      b = read_configfile(this->userfilename, this->cache);
      return (a | b);
   }
   return read_configfile(this->userfilename, this->cache);
}


bool ConfigFile::read_configfile(char *filename, StringMap& c) {
   char readbuf[100];
   FILE *fp;
   int i, line;
   string section;

   line = 0;
   fp = fopen(filename, "r");
   if(fp == NULL) return false;
   while(fgets(readbuf, sizeof(readbuf), fp) != NULL) {
      line++;
      string buf(readbuf);
      /* Clear out leading and trailing whitespace, including the newline */
      buf.erase(0, buf.find_first_not_of(string(" \t")));
      i = buf.find_last_not_of(string(" \t\n\r"));
      buf.erase(i+1, buf.length()-i-1);

      /* Skip comment and blank lines */
      if((buf.size() == 0) || (buf.find('#') == 0)) continue;

      /* Check for new section header */
      if(buf.find('[') == 0) {
         i = buf.find_first_of(']');
         if(i < 0) goto parse_error;
         section = buf.erase(i);
         section.erase(0, 1);
         continue;
      }

      i = buf.find('=');
      if(i < 0) goto parse_error;

      /* Extract the value and remove leading whitespace */
      string value(buf, i+1, buf.length()-i-1);
      value.erase(0, value.find_first_not_of(string(" \t")));

      /* Extract the key and remove trailing whitespace */
      string key(buf, 0, i);
      i = key.find_last_not_of(string(" \t"));
      key.erase(i+1, key.length()-i-1);

      i = key.find('.');
      if(i < 0) {
         /* Windows ini style entry so make sure there's a section */
         if(section.size() == 0)
            THROW_ERROR(runtime_error, "Variable defined outside " \
              "of a section in %s, line %d", filename, line);
         /* Create the actual map key */
         key = section + "." + key;
      }

      c.erase(key);
      c.insert(StringMap::value_type(key, value));
   }
   fclose(fp);
   return true;

parse_error:;
   THROW_ERROR(runtime_error, "Error parsing line %d in %s\n",
     line, filename);
}


bool ConfigFile::writeback(void) {
   FILE *fp;

   fp = fopen(this->userfilename, "w+");
   if(fp == NULL) return false;

   StringMap globals;
   if(this->sysfilename != NULL) {
      /* Read in the system-wide vars so we can compare them. */
      read_configfile(this->sysfilename, globals);
   }

   StringMap::iterator i = this->cache.begin();
   for(; i != this->cache.end(); i++) {
      /* Check the system-wide config */
      StringMap::iterator j = globals.find(i->first);
      if(i != this->cache.end()) {
         /* The variable exists, compare the value */
         if(i->second == j->second) continue;
      }
      fprintf(fp, "%s=%s\n", i->first.c_str(), i->second.c_str());
   }
   fclose(fp);

   return true;
}


bool ConfigFile::get_integer(const string& section, const string& key,
   long *val)
{
   StringMap::iterator i;
   string index;

   index = section + string(".") + key;
   i = this->cache.find(index);
   if(i == this->cache.end())
      return false;

   string value = i->second;
   *val = strtol(value.c_str(), NULL, 0);

   return true;
}


void ConfigFile::set_integer(const string& section, const string& key,
   long val)
{
   string index, value;
   char charbuf[20];

   index = section + string(".") + key;
   snprintf(charbuf, sizeof(charbuf), "%ld", val);
   value = string(charbuf);

   this->cache.erase(index);
   this->cache.insert(StringMap::value_type(index, value));
}


bool ConfigFile::get_integerv(const string& section, const string& key,
   long *valarray, unsigned int *arraylen)
{
   StringMap::iterator i;
   string index;
   int value_pos, next_value_pos;
   unsigned int count;

   index = section + string(".") + key;
   i = this->cache.find(index);
   if(i == this->cache.end())
      return false;

   string value = i->second;
   count = 0;
   value_pos = 0;
   while((value_pos < (int)value.length()) && (count < *arraylen)) {
      next_value_pos = value.find(',', value_pos);
      if(next_value_pos < 0) {
         /* Last entry. Set the next position to the end of the string */
         next_value_pos = value.length();
      }

      if(next_value_pos > value_pos) {
         string intval = value.substr(value_pos, (next_value_pos - value_pos));
         valarray[count] = strtol(intval.c_str(), NULL, 0);
         count++;
      }
      value_pos = next_value_pos + 1;
   }
   *arraylen = count;

   return true;
}


bool ConfigFile::get_boolean(const string& section, const string& key,
   bool *val)
{
   StringMap::iterator i;
   string index;

   index = section + string(".") + key;
   i = this->cache.find(index);
   if(i == this->cache.end())
      return false;

   string value = i->second;
   if((value == "true") || (value == "1") || (value == "yes") ||
      (value == "on"))
   {
      *val = true;
   } else {
      *val = false;
   }

   return true;
}


void ConfigFile::set_boolean(const string& section, const string& key,
   bool val)
{
   string index, value;

   index = section + string(".") + key;
   if(val) {
      value = string("true");
   } else {
      value = string("false");
   }

   this->cache.erase(index);
   this->cache.insert(StringMap::value_type(index, value));
}


bool ConfigFile::get_string(const string& section, const string& key,
   char *buf, int buflen)
{
   StringMap::iterator i;
   string index;

   index = section + string(".") + key;
   i = this->cache.find(index);
   if(i == this->cache.end())
      return false;

   string value = i->second;
   strncpy(buf, value.c_str(), buflen);
   if(buflen > 0)
      buf[buflen-1] = 0;

   return true;
}


void ConfigFile::set_string(const string& section, const string& key,
   const char *buf)
{
   string index, value;

   index = section + string(".") + key;
   value = string(buf);

   this->cache.erase(index);
   this->cache.insert(StringMap::value_type(index, value));
}


vector<string> ConfigFile::get_sections(void) {
   string prev_section;
   vector<string> v;

   StringMap::iterator it = this->cache.begin();
   for(; it != this->cache.end(); it++) {
      int i = it->first.find('.');
      if(i < 0) {
         /* Should never happen */
         continue;
      }
      string section(it->first, 0, i);
      if(section != prev_section) {
         prev_section = section;
         v.push_back(section);
      }
   }

   return v;
}


Does anyone have any idea what would cause this?
Back to top
View user's profile Send private message
MotivatedTea
Apprentice
Apprentice


Joined: 06 Nov 2006
Posts: 269
Location: Toronto, Canada

PostPosted: Tue Jul 12, 2011 5:32 am    Post subject: Re: Compile Error Reply with quote

Jon Wilder wrote:
Does anyone have any idea what would cause this?


Yes: it's a bug in the code. getenv() and strtol() are both in stdlib.h, but the author has not included it. If you want to fix that version of the code, add the line:
Code:
#include <stdlib.h>
near the top in among the other #include statements. However, a quick check of the Odyssey website shows that there is a newer version of the code available compared to what you're using. A newer version might have that bug fixed already (and -- who knows? -- possibly others).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum