How to use android logging (LOGD, LOGE) in NDK library

9,237 views
Skip to first unread message

Loic

unread,
Aug 21, 2009, 9:50:23 AM8/21/09
to android-ndk
Hello,
I just want to log messages from my NDK library but trying to include
cutils/log.h is not working in the NDK toolchain.
what should I use ?
thanks,
Loic

Pawel Veselov

unread,
Aug 21, 2009, 4:20:12 PM8/21/09
to andro...@googlegroups.com
I've been using this:

...
#include <android/log.h>
...
#define LOG_TAG "barabashka" // text for log tag

...
__android_log_print(ANDROID_LOG_INFO, LOG_TAG,
"resolving function %s, id %d", symbols[f_id].name, f_id);
...


You can check android/log.h for more logging function definitions:
build/platforms/android-1.5/common/include/android/log.h

David Turner

unread,
Aug 21, 2009, 4:22:27 PM8/21/09
to andro...@googlegroups.com
use <android/log.h> instead

Jason Proctor

unread,
Aug 21, 2009, 5:08:59 PM8/21/09
to andro...@googlegroups.com
i tried this and got link errors -- how does one add liblog.so to the build?

thanks!
--
jason.software.particle

Pawel Veselov

unread,
Aug 21, 2009, 7:06:04 PM8/21/09
to andro...@googlegroups.com
On Fri, Aug 21, 2009 at 2:08 PM, Jason
Proctor<jason.and...@gmail.com> wrote:
>
> i tried this and got link errors -- how does one add liblog.so to the build?

You need to add '-llog' to your linker options. I'm not sure how to do
this properly, since I don't use NDK makefiles, but the log library is
along libc and others.

> thanks!

Rohit Grover

unread,
Aug 21, 2009, 7:20:31 PM8/21/09
to andro...@googlegroups.com
LOCAL_LDLIBS := -Lbuild/platforms/android-1.5/arch-arm/usr/lib -llog


On Sat, Aug 22, 2009 at 5:08 AM, Jason Proctor <jason.and...@gmail.com> wrote:

i tried this and got link errors -- how does one add liblog.so to the build?

thanks!
--
jason.software.particle



LittleTester

unread,
Aug 24, 2009, 2:46:33 AM8/24/09
to android-ndk
Or you can use:

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog

On 22 авг, 05:20, Rohit Grover <rgrov...@gmail.com> wrote:
> LOCAL_LDLIBS := -Lbuild/platforms/android-1.5/arch-arm/usr/lib -llog

Jason Proctor

unread,
Aug 24, 2009, 3:15:40 PM8/24/09
to andro...@googlegroups.com
works great -- thanks.

>LOCAL_LDLIBS := -Lbuild/platforms/android-1.5/arch-arm/usr/lib -llog
>
>On Sat, Aug 22, 2009 at 5:08 AM, Jason Proctor
><<mailto:jason.and...@gmail.com>jason.and...@gmail.com>
>wrote:
>
>
>i tried this and got link errors -- how does one add liblog.so to the build?
>
>thanks!
>
>
>
>>I've been using this:
>>
>>...
>>#include <android/log.h>
>>...
>>#define LOG_TAG "barabashka" // text for log tag
>>
>>...
>> __android_log_print(ANDROID_LOG_INFO, LOG_TAG,
>> "resolving function %s, id %d", symbols[f_id].name, f_id);
>>...
>>
>>
>>You can check android/log.h for more logging function definitions:
>>build/platforms/android-1.5/common/include/android/log.h
>>
>>On Fri, Aug 21, 2009 at 6:50 AM,
>>Loic<<mailto:loic...@gmail.com>loic...@gmail.com> wrote:
>>>
>>> Hello,
>>> I just want to log messages from my NDK library but trying to include
>>> cutils/log.h is not working in the NDK toolchain.
>>> what should I use ?
>>> thanks,
>>> Loic
>>
>>
>
>--
>
>jason.software.particle
>
>
>
>
>
>

--
jason.software.particle
Reply all
Reply to author
Forward
0 new messages