About building of static libraries

875 views
Skip to first unread message

dhananjay

unread,
Feb 19, 2009, 8:13:39 AM2/19/09
to android-platform
Hi All,
I want to know how to avoid building of shared library in
android and start building static library in place .actually My ppc
Traget M/c doesnt support shared libraries.so I want bypass it and
build a static lib .can anybody guide me on this? please reply.

Regards,
DJ

David Turner

unread,
Feb 19, 2009, 5:22:01 PM2/19/09
to android-...@googlegroups.com
On Thu, Feb 19, 2009 at 2:13 PM, dhananjay <dhananja...@gmail.com> wrote:

Hi All,
          I want to know how to avoid building of shared library in
android and start building static library in place

replacing "include $(BUILD_SHARED_LIBRARY)" by "include $(BUILD_STATIC_LIBRARY)"; or
"include $(BUILD_HOST_SHARED_LIBRARY)" by "include $(BUILD_HOST_STATIC_LIBRARY)" in your Android.mk should be enough

Also use LOCAL_STATIC_LIBRARIES instead of LOCAL_SHARED_LIBRARIES to refer to them in another package.
 
.actually My ppc
Traget M/c doesnt support shared libraries.so I want bypass it and
build a static lib .can anybody guide me on this? please reply.

I don't understand what you mean. Do you mean you want to build Android binaries for a platform where shared libraries are not supported by Linux ? If so I think there are few chances you'll be able to have Android run on it.

Something else ?
 

Regards,
DJ

Dhananjay Joshi

unread,
Feb 20, 2009, 9:21:47 AM2/20/09
to android-...@googlegroups.com
Hi
 yes, your understanding is correct I want to build Android binaries for a platform where shared libraries are not supported by Linux.
so as per your instructions i have changed this "include $(BUILD_SHARED_LIBRARY)" to "include $(BUILD_STATIC_LIBRARY)";
in external/sqlite/dist/Android.mk file for libsqlite module.
also the shared lib it requires that are nothing but
i have changed this
LOCAL_SHARED_LIBRARIES += liblog \
            libicuuc \
            libicui18n
 to
LOCAL_STATIC_LIBRARIES += liblog \
            libicuuc \
            libicui18n
but it is not building these static lib,it is simply skipping building of these static libs
and throwing the error as
"no rule to make libc.so needed by sqlite3 " which is nothing but target executable.
can you guide me on this?
please reply
Regards,
DJ

Ludwig

unread,
Feb 20, 2009, 9:43:53 AM2/20/09
to android-...@googlegroups.com
but it is not building these static lib,it is simply skipping building of these static libs
and throwing the error as
"no rule to make libc.so needed by sqlite3 " which is nothing but target executable.
can you guide me on this?
please reply
Regards,
DJ

I think what you are seeing is that the make process is trying to determine all dependencies and making them first and since sqlite3 depends on libc.so is tries to make this first. Once it is made it would come back to your static libraries... You might have to change all LOCAL_SHARED_LIBRARIES to static, but I am not sure where this will lead to.

Ludwig

David Turner

unread,
Feb 20, 2009, 12:41:20 PM2/20/09
to android-...@googlegroups.com
On Fri, Feb 20, 2009 at 3:21 PM, Dhananjay Joshi <dhananja...@gmail.com> wrote:

Hi
 yes, your understanding is correct I want to build Android binaries for a platform where shared libraries are not supported by Linux.

That's interesting, I'm curious to see what the result would be and how well it would run. Please keep us posted about your progress.
 
so as per your instructions i have changed this "include $(BUILD_SHARED_LIBRARY)" to "include $(BUILD_STATIC_LIBRARY)";
in external/sqlite/dist/Android.mk file for libsqlite module.
also the shared lib it requires that are nothing but
i have changed this
LOCAL_SHARED_LIBRARIES += liblog \
            libicuuc \
            libicui18n
 to
LOCAL_STATIC_LIBRARIES += liblog \
            libicuuc \
            libicui18n

If you do that, you will need to replace BUILD_SHARED_LIBRARY by BUID_STATIC_LIBRARY into the Android.mk of libicuuc, libcicui18n
and all the other libraries they depend on.

I think it would probably be easier for you to change the build system to never build a shared library instead, so that you would be able
to let all the Android.mk unchanged. Otherwise, this is going to require changing about 900 files.

To do this, look at the content of build/core, especially the following files:

definitions.mk  => a bunch a definitions that are later used to perform various stuff, e.g. compile a source code into an object file, etc..
dynamic_library.mk => what $(BUILD_SHARED_LIBRARY) really points to
static_library.mk => what $(BUILD_STATIC_LIBRARY) really points to

you will need to change the interpretation of LOCAL_SHARED_LIBRARIES into LOCAL_STATIC_LIBRARIES at some point, but
I can't tell you exactly where.

If you don't want to do that, you may want to do a massive find/replace for LOCAL_SHARED_LIBRARIES => LOCAL_STATIC_LIBRARIES,
etc.. but then you'll have to deal with conflicting definitions (some Android.mk are used to build both a static and shared library)

Hope this helps
 

Dhananjay Joshi

unread,
Feb 24, 2009, 8:21:10 AM2/24/09
to android-...@googlegroups.com

Hi david
 I did the same thing as you told i.e changing  Android.mk of liblog,libicuuc,libicu18n to build static library.
and include static_library.mk in each of this makfile ,after that my assumption was make should go to template file and

should build static library,but it is hitting the error as

make: *** No rule to make target `out/target/product/generic/obj/lib/libsqlite.so', needed by

`out/target/product/generic/obj/EXECUTABLES/sqlite3_intermediates/LINKED/sqlite3'.  Stop.

i.e it is skipping these libraries and directly jumping to build sqlite3 as device command line tool.

Also i dont want make to build any of the bionic library because i have my own libc.a,libstdc++.a and libdl.a libraries i

want to give path of these sys libraries while building any of the static library.

I am confused where to give the path for these libraries now?
also for libsqlite it is checking for liblog.so and in turn for liblog.so it is checking for libc.so ,this i come to know by

observing log file,but nowhere in makefile of liblog.so it is stating libc.so,so that i can prevent building of this

library,and give the path of my archives.

also for shared libraries they have written dynamic_binary.mk to collect all the dependencies but for static libraries no

file to collect the dependencies.


can you guide me on this?

Regards,
DJ.


David Turner

unread,
Feb 24, 2009, 10:03:47 AM2/24/09
to android-...@googlegroups.com
On Tue, Feb 24, 2009 at 2:21 PM, Dhananjay Joshi <dhananja...@gmail.com> wrote:

Hi david
 I did the same thing as you told i.e changing  Android.mk of liblog,libicuuc,libicu18n to build static library.
and include static_library.mk in each of this makfile ,after that my assumption was make should go to template file and

should build static library,but it is hitting the error as

make: *** No rule to make target `out/target/product/generic/obj/lib/libsqlite.so', needed by

`out/target/product/generic/obj/EXECUTABLES/sqlite3_intermediates/LINKED/sqlite3'.  Stop.

i.e it is skipping these libraries and directly jumping to build sqlite3 as device command line tool.

Yes, because the Android.mk in sqlite3 has a line like LOCAL_SHARED_LIBRARIES := liblog, or something similar.
You need to change this in anything that depends on liblog, etc... Due to the vast dependencies in the system, it means you're going to either have to change all Android.mk files, or hack the build system itself to totally avoid shared libraries.

In my previous message, I recommended you the second approach.
 

Also i dont want make to build any of the bionic library because i have my own libc.a,libstdc++.a and libdl.a libraries i

want to give path of these sys libraries while building any of the static library.

I am confused where to give the path for these libraries now?

Ah, you're in it for a very rough ride, but if you want to, have a look at build/core/combo/linux-arm.mk (you probably need to write an equivalent file for your own target platform if it's not ARM).

Reply all
Reply to author
Forward
0 new messages