Compiling the native static libraries for Windows
To build the Windows version of libraries, we need a C++ compiler. We use MinGW with the GCC toolchain described in Chapter 1, Establishing a Build Environment. For each library, we have a collection of source-code files, and we need to get the static library, a file with the .a
extension.
Getting ready
Let us assume the src
directory contains the source code of a library we need to build for Android.
How to do it...
- Let us start with writing a makefile:
CFLAGS = -I src
This line defines a variable with a list of compiler command-line parameters. In our case, we instruct the compiler to search the
src
directory for header files. If the library source code spans across many directories, we need to add the–I
switch for each of the directories. - Next, we add the following lines for each source file:
<SourceFile>.o: gcc $(CFLAGS) –c <SourceFile>.cpp –o <SourceFile>.o
<SourceFile>
should be replaced by the...