epoll usage inside ndk

1,133 views
Skip to first unread message

andreih

unread,
Jan 29, 2010, 7:40:51 AM1/29/10
to android-ndk
Hello all,
I've been working on some networking code based on linux epoll system.
I've seen that the headers are in the ndk, but when I try to link the
library, it fails with;
out/apps/Proto/objs/Proto/./src/sdk/NetTransmitter.o: In function
`NetTransmitter::Work(bool)':
apps/Proto/project/jni/./src/sdk/NetTransmitter.cpp:911: undefined
reference to `epoll_wait(int, epoll_event*, int, int)'
apps/Proto/project/jni/./src/sdk/NetTransmitter.cpp:909: undefined
reference to `epoll_wait(int, epoll_event*, int, int)'

I get no compile errors, and I also don't see any library I can link
up too.
Is it really supported or it's off-limits for now? Any suggestions?

Thanks,
Andrei

Jack Palevich

unread,
Feb 8, 2010, 8:36:29 PM2/8/10
to android-ndk
Are you using C++? I think we have found a bug in the NDK sys/epoll.h
header where it does not properly use the extern "C" statement to
ensure the epoll function names are not mangled. The header should
have text like this:

#ifdef __cplusplus
extern "C" {
#endif

... all function declarations go here

#ifdef __cplusplus
};
#endif

This will be fixed in a future version of the NDK. In the meantime you
can work around it by modifying your copy of sys/epoll.h

David Turner

unread,
Feb 8, 2010, 11:24:09 PM2/8/10
to andro...@googlegroups.com
Another simpler solution is to embed the include as in:

extern "C" {
#include <sys/epoll.h>
}

in your C++ code.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


andreih

unread,
Mar 9, 2010, 4:18:54 AM3/9/10
to android-ndk
I've just switched to ndk-r3 and none of the fixes work any more.
extern "C"{} does nothing nor does the

#include <sys/cdefs.h>
__BEGIN_DECLS
...
__END_DECLS

in the epoll.h similar to the other headers in the ndk package. Am I
missing something?


On Feb 9, 6:24 am, David Turner <di...@android.com> wrote:
> Another simpler solution is to embed the include as in:
>
> extern "C" {
> #include <sys/epoll.h>
>
> }
>
> in your C++ code.
>

> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>

Reply all
Reply to author
Forward
0 new messages