0

我知道还有其他具有相同标题的问题,但没有一个问题与我相同。

我有两个项目。其中一个构建了一个库,另一个构建了一个使用该库的应用程序。

当我建立图书馆时,一切都好。它创建一个包含库的 .a 文件。当我尝试构建第二个项目时,我收到以下消息:

Undefined symbols for architecture armv7:
  "_SPLite3_rtree_geometry_callback", referenced from:
      _register_spatialite_sql_functions in liblibspatialite.a(spatialite.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

那很糟。一开始不知道在说什么,后来研究了一下,发现这个库可能还没有为armv7建库,于是我用lipo命令查看了架构:

lipo -info liblibspatialite.a

这会产生以下输出。

Non-fat file: liblibspatialite.a is architecture: armv7

好的,所以架构是正确的。然后呢?也许检查符合库的 .o 文件的符号。为此,我使用了 nm 命令:

nm spatialite.o | grep SPLite3_rt

产生以下输出:

U _SPLite3_rtree_geometry_callback

我检查了 nm 的联机帮助页,发现符号前的 U 表示它未定义。所以似乎就是这样。该符号显示为未定义。我在另一个工作区中有另一个版本的项目。我已经检查过了,它产生了一个工作库。nm 命令在该其他版本上返回以下内容:

0000e5f6 T _SPLite3_rtree_geometry_callback
0018c668 S _SPLite3_rtree_geometry_callback.eh

所以,有了这个库,它就可以工作了,而且很好。我试图找到两个项目的构建选项的差异,但它们对我来说看起来是一样的。如果我在项目属性的编译器部分中包含库的源文件,我可以使用库的第一个版本进行构建。(选择目标-> 构建阶段-> 编译源),但我认为这不是使用库的重点。

所以,我想知道我该怎么做才能将 _SPLite3_rtree_geometry_callback 包含在库中。

提前致谢。

编辑:

更多信息。在 spatialite.c 中,有以下代码:

#define sqlite3_rtree_geometry_callback SPLite3_rtree_geometry_callback

SQLITE_API int sqlite3_rtree_geometry_callback(
sqlite3 *db,
  const char *zGeom,
  int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
  void *pContext
);

编辑2:

该方法的代码:

/*
** Register a new geometry function for use with the r-tree MATCH operator.
*/

SQLITE_API int sqlite3_rtree_geometry_callback(
  sqlite3 *db,
  const char *zGeom,
  int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *),
  void *pContext
){
  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */

  /* Allocate and populate the context object. */
  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));
  if( !pGeomCtx ) return SQLITE_NOMEM;
  pGeomCtx->xGeom = xGeom;
  pGeomCtx->pContext = pContext;

  /* Create the new user-function. Register a destructor function to delete
  ** the context object when it is no longer required.  */
  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, 
      (void *)pGeomCtx, geomCallback, 0, 0, doSqlite3Free
  );
}
4

3 回答 3

0

检查是否spacialite.c已添加到库的目标中。

于 2012-08-30T14:44:54.017 回答
0

您必须在预处理宏中指定 SQLITE_ENABLE_RTREE

于 2012-08-30T16:12:24.910 回答
0

行。这看起来很奇怪,但看起来我终于修好了。一切都正确定义,所以为什么它不工作我不知道。

我正在使用 xcode 目标首选项来定义预处理器宏。取而代之的是,我将 SQLITE_ENABLE_RTREE 更改为 .pch 文件,然后构建包含缺少的符号。

于 2012-09-03T09:44:17.753 回答