4javier
4javier

Reputation: 639

Linker can't find function

Im trying to build an Ubuntu Touch tree, based on an Aosp tree I already correctly built. It fails with this error

CAPEWrapper.cpp:16: error: undefined reference to '__xlog_buf_printf'

this is the header that file includes

#include "CAPEWrapper.h"

which on cascade includes

#include <cutils/xlog.h>

which in turn defines

#if defined(__cplusplus)
extern "C" {
#endif

int __xlog_buf_printf(int bufid, const struct xlog_record *rec, ...);

#if defined(__cplusplus)
}
#endif

I suspect that my g++ doesn't set __cplusplus macro. Could it be a realistic scenario with this kind of error? If this could be the problem, should I need to specify a standard implementation with "stdc=something" to solve it?

Any other idea is welcome.

Upvotes: 0

Views: 2153

Answers (2)

4javier
4javier

Reputation: 639

In the end, I found that the modules was listed inside a macro called LOCAL_WHOLE_STATIC_LIBRARIES, that in Android environment passes its content to the --whole-archive flag of GCC linker.

Upvotes: 0

Jeremy
Jeremy

Reputation: 5321

Make sure that your project is linking libcutils, and that it's linking it in the correct order (i.e. that -lcutils appears in the linker command line after any module that depends on it).

Upvotes: 3

Related Questions