将使用Clang构建的库添加到使用GCC构建的iOS应用程序时出现链接错误 [英] Link error adding library built with Clang to iOS app built with GCC

查看:156
本文介绍了将使用Clang构建的库添加到使用GCC构建的iOS应用程序时出现链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Dropbox Sync API(v1.1.2)添加到使用Marmalade(v6.3)构建的iOS应用中.我收到以下链接错误:

I'm trying to add the Dropbox Sync API (v1.1.2) to an iOS app built with Marmalade (v6.3). I'm getting the following link error:

Undefined symbols for architecture armv7:
"___udivmodsi4", referenced from:
_sqlite3BitvecSet in libDropbox.a(sqlite3.o)
_sqlite3BitvecClear in libDropbox.a(sqlite3.o)
_sqlite3BitvecTest in libDropbox.a(sqlite3.o)
ld: symbol(s) not found for architecture armv7

搜索该错误消息的相关部分,可以发现某个SQLCipher库的许多用户遇到相同的问题,并建议该问题是由用于构建该库的编译器和使用该库的各个项目不一致引起的

Googling for pertinent parts of that error message finds a number of users of a certain SQLCipher library experiencing the same issue, and suggestions that the problem is caused by an inconsistency of the compilers used to build that library and the various projects using it.

由于我们的项目的构建系统是由Marmalade工具集设置的,因此我认为不建议更改编译器(目前,我相信是Marmalade提供的GCC 4.4版本).

As the build system for our project is set up by the Marmalade toolset, changing the compiler (currently a version of GCC 4.4 supplied by Marmalade, I believe) is not an option, I think.

谁能更准确地告诉我出了什么问题?还有其他解决此问题的方法吗?

Can anyone tell me more precisely what is going wrong? Are there any other workarounds to this problem?

推荐答案

另一个答案是正确的.但是,对于这个特定问题(如果仅是这些链接器错误而出现),我会看到两种解决方法:

The other answer is correct. However, for this specific problem (if these are the only linker errors you are getting) I see two workarounds:

  1. 从包含sqlite3BitvecSet的sqlite3中获取源代码,并在您自己的项目中编译这些函数以覆盖该库.他们会选择您自己的编译器提供的所有divmod支持.
  2. 实施您自己的udivmodsi4.您不必实现按位除法(尽管您可以从GCC源代码中获得基本的C实现).您只需在本机操作中实现它,然后让您的编译器调用所需的任何内部支持即可.
  1. Grab the source from sqlite3 that includes sqlite3BitvecSet and compile those functions in your own project to override the library. They will pick up whatever divmod support is offered by your own compiler.
  2. Implement your own udivmodsi4. You don't have to implement bitwise division (although you can go get that basic C implementation from the GCC source). You just have to implement it in native operations and let your compiler call whatever internal support it needs.

这是未经测试的,但是应该给您基本的想法.您可能需要在名称上添加更多下划线,以匹配其他构建环境的行为/命名:

This is untested, but should give you the basic idea. You may need more underscores on the name to match the behavior/naming of the other build environment:

unsigned long
udivmodsi4(unsigned long num, unsigned long den, int modwanted)
{
    if (modwanted)
        return num % den;
    else
        return num / den;
}

这篇关于将使用Clang构建的库添加到使用GCC构建的iOS应用程序时出现链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆