Recently in the company to learn the development of the NDK, the more learning the more the development of Java than C + + is more happy, at least in Java, compile the time to set a line of error, then basically that row has a problem, however, C + + is not so, my development environment is eclipse;
1, the first encounter of a wonderful problem is:
Function ' __builtin_bswap16 ' could not being resolved
This is caused by the use of htons, engaged in a half-day or not resolved, finally there is no way to set the inside C/c++general:code anallysis this error to ban, the result of success through compiling, I, I guess is my compilation has a bug, this thing should be where there is a definition, But the compile time did not find the direct error. If you ignore this error, successfully compile, link to the time can be found this symbol. This is my own speculation of the explanation, some people know that the message of popular science, Gray often thanks.
2, a variety of things can not be resolved
The first thing to understand is that out of our compilation of Ghost animals, a few of this problem is caused by the introduction of header files, I developed with the Mac, NDK programming header files should be the NDK tool directory, but I found that I introduced the header file is in the Mac system directory under the/usr/include directory, If you open the Include label for C/s + + Paths and Symbols, you can see that there is/usr/include, I do NDK development, although the MAC system directory of the header files in the same NDK directory is the same, this can understand, after all, Mac is Unix Like system, the Linux kernel used by Android, but these files may be different, after all, cross-platform may have been modified, if we use the system directory of the header file, and using the system's static library, this is problematic.
3, grammar no problem, why compile error
This is usually a problem with the procedure, check the header file of the Include
4, clearly contains the header file, the function of the name is in the inside, for the hair compiled or reported undefined reference?
Undefined reference to
First forget the header file what this kind of thing should not forget, then contains the header file why still hold a mistake, the first solution is not to include the header file, I put. C source files included, yes this solves the problem, but this and the heart of the compiler link theory is not the same AH. Think and think, can only be interpreted as the compilation of the source file, the compiler is the use of C + + symbol decoration (so tall on a point, also can be said to be a function signature, that is, the source code of the function or variable end in the target file name, the different compilers, even different versions of the compiler will not be the same), However, the source file compiler referencing that file is compiled by C, so the two-place name is the same as in the source code, but the name is different after the actual compilation, so there is a problem with the symbol undefined. After such speculation, then the solution will be clear to the heart, the inclusion of the header file with the extern "C" wrapped up, the result is really successful.
An unresolved symbol for the Android NDK development Crawl Pits