Android build error with -llzo2 and -luuid on 64 bits ubuntu

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Android build error with -llzo2 and -luuid on 64 bits ubuntu

18,812 Views
shaojun_wang
NXP Employee
NXP Employee

When build ICS on 64 bits ubuntu 11.10, if there is -llzo2 in some Android.mk, even you have already run “sudo apt-get install liblzo2-dev”, you may still meet some build error.

For example, in attached mtd-utils package, there is -llzo2 in mtd-utils/mkfs.ubifs/Android.mk, so you may meet this kind of error message:

 

host Executable: mkfs.ubifs (out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs)

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../liblzo2.a when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/liblzo2.a when searching for -llzo2

/usr/bin/ld: cannot find -llzo2

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs] Error 1

 

To fix the error, you should install 32 bits lzo2 and luuid to your 64 bits ubuntu. Below is the example of lzo2.

 

1. Down 32 bits lzo2, then unpack it to a folder. You can get the lzo2 deb package in the attachmemt.

$ sudo mkdir /usr/lib/liblzo2_i386

$ sudo dpkg -x liblzo2-dev_2.05-1_i386.deb /usr/lib/liblzo2_i386/

$ sudo dpkg -x liblzo2-2_2.05-1_i386.deb /usr/lib/liblzo2_i386/

 

2. Change the link of liblzo2 from default 64 bit lib to 32 bit lib.

$ cd /usr/lib/

$ sudo rm liblzo2.a

$ sudo rm liblzo2.so

$ sudo rm liblzo2.so.2

$ sudo ln -s liblzo2_i386/usr/lib/liblzo2.a liblzo2.a

$ sudo ln -s liblzo2_i386/usr/lib/liblzo2.so.2.0.0 liblzo2.so

$ sudo ln -s liblzo2_i386/usr/lib/liblzo2.so.2.0.0 liblzo2.so.2

Original Attachment has been moved to: liblzo2-2_2.05-1_i386.deb.zip

Original Attachment has been moved to: liblzo2-dev_2.05-1_i386.deb.zip

Original Attachment has been moved to: mtd-utils.tgz

Original Attachment has been moved to: uuid-dev_2.20.1-1ubuntu3_i386.deb.zip

Labels (1)
20 Replies

4,131 Views
saurabh206
Senior Contributor III

Use this

# Copyright 2009 The Android Open Source Project

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \

    mkfs.ubifs.c \

    crc16.c \

    crc32.c \

    devtable.c \

    lpt.c \

    compr.c \

    hashtable/hashtable.c \

    hashtable/hashtable_itr.c

#LOCAL_CC := /usr/bin/gcc

#LOCAL_CXX := /usr/bin/g++

LOCAL_CFLAGS = -O2 -Wall

LOCAL_CFLAGS+= -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -m64

LOCAL_CFLAGS+= -Wmissing-prototypes -Winline

LOCAL_LDFLAGS += -L/usr/lib/x86_64-linux-gnu

LOCAL_LDLIBS:= -lz -llzo2 -lm -luuid -m64

LOCAL_C_INCLUDES += $(LOCAL_PATH)/

LOCAL_C_INCLUDES += /usr/include/

LOCAL_C_INCLUDES += $(LOCAL_PATH)/hashtable

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := mkfs.ubifs

include $(BUILD_HOST_EXECUTABLE)

0 Kudos

4,131 Views
shinuv
Contributor I

I have tried the same and its giving error. so i changed as

# Copyright 2009 The Android Open Source Project

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \

    mkfs.ubifs.c \

    crc16.c \

    crc32.c \

    devtable.c \

    lpt.c \

    compr.c \

    hashtable/hashtable.c \

    hashtable/hashtable_itr.c

LOCAL_CC := /usr/bin/gcc

LOCAL_CXX := /usr/bin/g++

LOCAL_CFLAGS = -O2 -Wall

LOCAL_CFLAGS+= -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -m32

LOCAL_CFLAGS+= -Wmissing-prototypes -Winline

LOCAL_LDFLAGS += -L/usr/lib/i386-linux-gnu

LOCAL_LDLIBS:= -lz -llzo2 -lm -luuid -m32

LOCAL_C_INCLUDES += $(LOCAL_PATH)/

LOCAL_C_INCLUDES += /usr/include/

LOCAL_C_INCLUDES += $(LOCAL_PATH)/hashtable

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := mkfs.ubifs

include $(BUILD_HOST_EXECUTABLE)

-----------------------------------------------------------------------------------------

now following error as getting

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++

/usr/bin/ld: cannot find -lstdc++

collect2: ld returned 1 exit status

0 Kudos

4,131 Views
shinuv
Contributor I

gcc-multilib_4.6.3-1ubuntu5 is already installed. But i am not able to install g++-multilib_4.6.3-1ubuntu5 giving error as 'E: Internal Error, No file name for libuuid1'

0 Kudos

4,131 Views
saurabh206
Senior Contributor III

Hi,

Shinu

Just try to delete whole output directory.

0 Kudos

4,128 Views
shinuv
Contributor I

Hi Saurabh,

I deleted output directory and compiled again. Still i am getting the following errors

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++

/usr/bin/ld: cannot find -lstdc++

Thanks

0 Kudos

4,131 Views
saurabh206
Senior Contributor III

Hi,

You need to add -m64  in Android.mk,

Check my previous reply.

0 Kudos

4,131 Views
shinuv
Contributor I

Hi,

I added -m64 then i am getting following errors

Export includes file: external/mtd-utils/mkfs.ubifs/Android.mk -- out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/export_includes

host Executable: mkfs.ubifs (out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs)

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/liblzo2.a when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/../lib/liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/../lib/liblzo2.a when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../liblzo2.a when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/liblzo2.so when searching for -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/liblzo2.a when searching for -llzo2

/usr/bin/ld: cannot find -llzo2

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libuuid.so when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libuuid.a when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/../lib/libuuid.so when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/../lib/libuuid.a when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libuuid.so when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libuuid.a when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/libuuid.so when searching for -luuid

/usr/bin/ld: skipping incompatible /usr/lib/libuuid.a when searching for -luuid

/usr/bin/ld: cannot find -luuid

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs] Error 1

------------------------------------------------------------------------------------------------------------------------------------------------

so i added LOCAL_LDFLAGS += -L/usr/lib/i386-linux-gnu instead of LOCAL_LDFLAGS += -L/usr/lib/x86_64-linux-gnu and -m32

then the above error are gone but getting error as

Export includes file: external/mtd-utils/mkfs.ubifs/Android.mk -- out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/export_includes

host Executable: mkfs.ubifs (out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs)

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++

/usr/bin/ld: cannot find -lstdc++

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs] Error 1

Thanks

0 Kudos

4,131 Views
shinuv
Contributor I

Hi all,

I am new to Android.

I am trying to compile Android source in ubuntu 12.04 and i have done the changes as said in the previous post but its giving following errors

Checking API: checkapi-current
host Executable: mkfs.ubifs (out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs)
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.a when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.a when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.a when searching for -lc
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs] Error 1

Please help me to resolve this.

Thanks

0 Kudos

4,131 Views
saurabh206
Senior Contributor III

Hi,

Shinu

Which android version you are trying to build?

What processor you are using 32 bit or 64 bit and same for ubuntu?

Regards

Saurabh

0 Kudos

4,131 Views
shinuv
Contributor I

Hi Saurabh,

Thanks for your quick reply.

android version is 4.2.2  , processor  and Ubuntu is 64 bit .

Thanks

0 Kudos

4,131 Views
saurabh206
Senior Contributor III

Hi

You can check your Android.mk has following.

LOCAL_CFLAGS+= -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -m64

LOCAL_CFLAGS+= -Wmissing-prototypes -Winline

LOCAL_LDFLAGS += -L/usr/lib/x86_64-linux-gnu

LOCAL_LDLIBS:= -lz -llzo2 -lm -luuid -m64

Regards

Saurabh

0 Kudos

4,131 Views
shinuv
Contributor I

Hi,

'/home/svg6kor/MRST/myandroid/external/mtd-utils/mkfs.ubifs/Android.mk' has the following

------------------------------------------------------------------------------------------------------------------------------------

# Copyright 2009 The Android Open Source Project

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \

    mkfs.ubifs.c \

    crc16.c \

    crc32.c \

    devtable.c \

    lpt.c \

    compr.c \

    hashtable/hashtable.c \

    hashtable/hashtable_itr.c

LOCAL_CC := /usr/bin/gcc

LOCAL_CXX := /usr/bin/g++

LOCAL_CFLAGS = -O2 -Wall

LOCAL_CFLAGS+= -Wpointer-arith -Wwrite-strings -Wstrict-prototypes

LOCAL_CFLAGS+= -Wmissing-prototypes -Winline

LOCAL_LDFLAGS += -L/usr/lib/x86_64-linux-gnu

LOCAL_LDLIBS:= -lz -llzo2 -lm -luuid

LOCAL_C_INCLUDES += $(LOCAL_PATH)/

LOCAL_C_INCLUDES += /usr/include/

LOCAL_C_INCLUDES += $(LOCAL_PATH)/hashtable

LOCAL_MODULE_TAGS := optional

LOCAL_MODULE := mkfs.ubifs

include $(BUILD_HOST_EXECUTABLE)

--------------------------------------------------------------------------------------------------------------------

In '/home/svg6kor/MRST/myandroid/external/mtd-utils/Android.mk'

added

LOCAL_LDFLAGS +=-L /usr/lib/

LOCAL_C_INCLUDES +=/usr/lib/uuid-dev/usr/include/

LOCAL_C_INCLUDES +=/usr/lib/liblzo2_i386/usr/include

Thanks

0 Kudos

4,131 Views
junfrost
Contributor I

Hello Everyone,@@@@ ! !

Here is my workaround, hope it will help you.

My enviroment is Ubuntu 12.04_64bit.I tried the solution of ShaojunWang and made some changes.

  1. I installed liblzo2-2_2.05-1_i386.deb ,liblzo2-dev_2.05-1_i386.deb and uuid-dev_2.20.1-1ubuntu3_i386.deb which are provided by ShaojunWang .
  • install liblzo2

    $ sudo mkdir /usr/lib/liblzo2_i386

    $ sudo dpkg -x liblzo2-dev_2.05-1_i386.deb /usr/lib/liblzo2_i386/

    $ sudo dpkg -x liblzo2-2_2.05-1_i386.deb /usr/lib/liblzo2_i386/

    $ cd /usr/lib/

    $ sudo rm liblzo2.a

    $ sudo rm liblzo2.so

    $ sudo rm liblzo2.so.2

    $ sudo ln -s liblzo2_i386/usr/lib/liblzo2.a liblzo2.a

    $ sudo ln -s liblzo2_i386/usr/lib/liblzo2.so.2.0.0 liblzo2.so

    $ sudo ln -s liblzo2_i386/usr/lib/liblzo2.so.2.0.0 liblzo2.so.2

  • install uuid-dev
    $ sudo mkdir /usr/lib/uuid-dev
    $ sudo dpkg -x uuid-dev_2.20.1-1ubuntu3_i386.deb  /usr/lib/uuid-dev/

    $ cd /usr/lib/
    $ sudo ln -s uuid-dev/usr/lib/i386-linux-gnu/libuuid.a  libuuid.a
    $ sudo ln -s uuid-dev/usr/lib/i386-linux-gnu/libuuid.so  libuuid.so

2. I modified the  external/mtd-utils/mkfs.ubifs/Android.mk.This fixed the "-llzo2 not found; uuid/uuid.h not found;".

    $ vi external/mtd-utils/mkfs.ubifs/Android.mk

    I added  the following  to  external/mtd-utils/mkfs.ubifs/Android.mk.

       LOCAL_LDFLAGS +=-L /usr/lib/

          LOCAL_C_INCLUDES +=/usr/lib/uuid-dev/usr/include/

          LOCAL_C_INCLUDES +=/usr/lib/liblzo2_i386/usr/include

0 Kudos

4,131 Views
anthonyharivel
Contributor II

Well I've got a work around....

When it fails:

> rm -rf out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/

> make BUILD_HOST_64bit=1

then it build the stupid mkfs.ubifs stuff in 64bit

then it fails again but further and then you can re-run normal "make" and it will build.

I know it's painfull solution but it breaks nothing.

Anthony

4,131 Views
jian
Contributor II

my virtual is ubuntu 12.04 x86_64, when I build the android 4.2.2 for sabresd_6dq I meet the error:

make: *** No rule to make target `out/target/product/sabresd_6dq/obj/STATIC_LIBRARIES/libubi_intermediates/export_includes', needed by `out/target/product/sabresd_6dq/obj/EXECUTABLES/recovery_intermediates/import_includes'.  Stop.

please help me!

     Thanks!

0 Kudos

4,131 Views
LeonardoSandova
Specialist I

I got the same error and decided to run a Ubuntu 10.04 virtually. I decided to do this due to the following text:

" Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master."

located on this page: Initializing a Build Environment | Android Developers

Anyway, on 10.4 besides the  packages mentioned on the later page, one needs to install these:

   65  sudo apt-get install sun-java6-jdk

   99  sudo apt-get install uuid uuid-dev

  103  sudo apt-get install zlib1g-dev liblz-dev

  106  sudo apt-get install liblzo2-2 liblzo2-dev

I had some trouble finding the first one (sun-java6-jdk) and the trick was to add another repo:


sudo add-apt-repository ppa:ferramroberto/java && sudo apt-get update

Leo


0 Kudos

4,131 Views
app025
Contributor III

Dear all,

both solutions break capability to compile 64 bit applications on Ubuntu 12.04 64bits.

Assuming you already installed liblzo2 and uuid running something like

$ sudo apt-get install liblzo2-dev uuid-dev

you can force 64bits compilation (using -m64 flag) applying the attached patch within android build system in the external/mtd-utils folder.

My Two Cents

Regards

Gigi

4,131 Views
dureshasanka
Contributor II

Hello Pierluigi Passaro,

I had the same problem and I applied the patch that you attached. Thank you very much for the patch file. Now the problem is solved.

But now I am getting some another problem. Could you please help me to solve this issue. I am new to these stuff.

I am using Ubuntu 10.10 64-bit to compile Android Jelly Bean. The error is,

install -D kernel_imx/arch/arm/boot/uImage  out/target/product/sabresd_6dq/uImage

install -D kernel_imx/arch/arm/boot/zImage  out/target/product/sabresd_6dq/kernel

Export includes file: external/mtd-utils/mkfs.ubifs/Android.mk -- out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/export_includes

host Executable: mkfs.ubifs (out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs)

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/crc16.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/crc32.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/devtable.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/lpt.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/compr.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/hashtable/hashtable.o' is incompatible with i386:x86-64 output

/usr/bin/ld: i386 architecture of input file `out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/hashtable/hashtable_itr.o' is incompatible with i386:x86-64 output

out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs.o: In function `calc_min_log_lebs':

/home/duresh/Documents/A03-Android/AndroidImagebuld/myandroid/external/mtd-utils/mkfs.ubifs/mkfs.ubifs.c:314: undefined reference to `__udivdi3'

/home/duresh/Documents/A03-Android/AndroidImagebuld/myandroid/external/mtd-utils/mkfs.ubifs/mkfs.ubifs.c:320: undefined reference to `__udivdi3'

out/host/linux-x86/obj/EXECUTABLES/mkfs.ubifs_intermediates/mkfs.ubifs.o: In function `lookup_inum_mapping':

/home/duresh/Documents/A03-Android/AndroidImagebuld/myandroid/external/mtd-utils/mkfs.ubifs/mkfs.ubifs.c:1161: undefined reference to `__umoddi3'

collect2: ld returned 1 exit status

The complete output is attached here and also Android.mk file which applied the patch also attached.

Please kindly help me with this matter.

Thanks in advance,

Duresh

0 Kudos

4,130 Views
rickchu
Contributor IV

Hi,

modify /external/mtd-utils/mkfs.ubifs/Android.mk

add "-lc" and "-lgcc" as below to fix undefined reference error.

LOCAL_LDLIBS:= -lz -llzo2 -lm -lc -lgcc -luuid -m64

tested with android_jb4.2.2_1.1.0-ga

Rick

0 Kudos

4,133 Views
simon_cai
Contributor III

dear shaojun

run sudo apt-get install liblzo2-dev:i386    ======>it will be OK.

THX

SIMON

0 Kudos