Opened 6 years ago

Closed 5 years ago

#875 closed defect (fixed)

atof undefined reference compiling with android NDK

Reported by: Alberto Bignotti Owned by: strk
Priority: trivial Milestone: 3.6.4
Component: Core Version: main
Severity: Critical Keywords: NDK atof
Cc:

Description

I use Geos (latest 31 May 2018) for android development using NDK Version 16.1

I occurrend in this issue: https://stackoverflow.com/questions/14571399/android-ndk-cant-find-atof-function

In my project I link statically libgeos.a and get "error: undefined reference to 'atof'" during compilation.

In order to make geos static lib work on my app, I need to modify "src/geom/Envelope.cpp" removing references to atof. After this update everything works fine.

https://git.osgeo.org/gitea/geos/geos/src/branch/master/src/geom/Envelope.cpp

From:

/*public*/
Envelope::Envelope(const string &str)
{
  // The string should be in the format:
  // Env[7.2:2.3,7.1:8.2]

  // extract out the values between the [ and ] characters
  string::size_type index = str.find("[");
  string coordString = str.substr(index + 1, str.size() - 1 - 1);

  // now split apart the string on : and , characters
  vector<string> values = split(coordString, ":,");

  // create a new envelopet
  init(::atof(values[0].c_str()),
       ::atof(values[1].c_str()),
       ::atof(values[2].c_str()),
       ::atof(values[3].c_str()));
}

To:

/*public*/
Envelope::Envelope(const string &str)
{
  // The string should be in the format:
  // Env[7.2:2.3,7.1:8.2]

  // extract out the values between the [ and ] characters
  string::size_type index = str.find("[");
  string coordString = str.substr(index + 1, str.size() - 1 - 1);

  // now split apart the string on : and , characters
  vector<string> values = split(coordString, ":,");

  // create a new envelopet
  init(strtod(values[0].c_str(), NULL),
       strtod(values[1].c_str(), NULL),
       strtod(values[2].c_str(), NULL),
       strtod(values[3].c_str(), NULL));
}

Change History (4)

comment:1 by robe, 6 years ago

Milestone: 3.6.33.6.4

comment:2 by Paul Ramsey <pramsey@…>, 5 years ago

In 56fc416/git:

Use strtod in Envelope constructor
References #875

comment:3 by Paul Ramsey <pramsey@…>, 5 years ago

In 74970cd/git:

Change Envelope constructor to use strtod
References #875

comment:4 by Paul Ramsey <pramsey@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 90cdcf0/git:

Use strtod in Envelope constructor
Closes #875

Note: See TracTickets for help on using tickets.