链接libcutils到本机的可执行文件 [英] Linking libcutils to native executable

查看:1576
本文介绍了链接libcutils到本机的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的可执行文件能够调用由libcuils支持的功能 - 就像 property_get(...)

I want my executable to be able to call functions supported by libcuils - like property_get(...).

在Android.mk我有: LOCAL_LDLIBS:= - lcutils

In the Android.mk I have: LOCAL_LDLIBS:=-lcutils

NDK建造的回报: 未定义的引用 property_get

ndk-build returns: undefined reference to property_get

添加default.properties与目标=机器人-9 并没有帮助。

Adding 'default.properties' with target=android-9 didn't help.

我使用的Andr​​oid NDK,R8E在Ubuntu。

I'm using android-ndk-r8e on ubuntu.

推荐答案

libcutils.so 是不是官方的原生API的一部分,它不是随NDK。你可以从任何设备甚至从模拟器拉它,​​它是整个版本和MODS的合理稳定,所以我不会使用它阻止你。

libcutils.so is not part of official native API, it is not distributed with NDK. You can pull it from any device or even from emulator, and it is reasonable stable across the versions and mods, so I will not discourage you from using it.

在另一方面中,接头通常会说

On the other hand, the linker would normally say

ld: error: cannot find -lcutils
collect2: ld returned 1 exit status

如果它说未定义的引用,它可能发现libcutils.so的地方在它的搜索路径。也许,这是一个错误的库。也许,你设定 LOCAL_LDLIBS 在您的Andr​​oid.mk静态库,因此被忽略。

If it said undefined reference, it probably found libcutils.so somewhere on its search path. Maybe, it was a wrong library. Maybe, you set LOCAL_LDLIBS for a static library in your Android.mk, and therefore it is ignored.

LOCAL_LDLIBS 只与

include $(BUILD_SHARED_LIBRARY)

include $(BUILD_EXECUTABLE)

这篇关于链接libcutils到本机的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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