linuxgoogle-chrome-extensionmakefilegoogle-nativeclientlibtomcrypt

Can't find valid lib when building Google Chrome NaCl application .nexe file


Problem - Can't build .nexe with libtomcrypt (-ltomcrypt) on 64bit machine

"skipping incompatible" or "not found".

/home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: skipping incompatible /home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/i686-nacl/usr/lib/libtomcrypt.a when searching for -ltomcrypt
/home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: skipping incompatible /home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/bin/../x86_64-nacl/usr/lib/libtomcrypt.a when searching for -ltomcrypt
/home/ME/nacl/pepper_35/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: cannot find -ltomcrypt

collect2: ld returned 1 exit status
make: *** [newlib/Release/my_module_unstripped_x86_32.nexe] Error 1

Makefile

Copy of existing example in downloaded nacl sdk. Modified with tomcrypt which result in -ltomcrypt flag.

VALID_TOOLCHAINS := newlib glibc pnacl linux

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..)

include $(NACL_SDK_ROOT)/tools/common.mk


TARGET = my_module
LIBS = ppapi_cpp ppapi pthread tomcrypt

CFLAGS = -Wall
SOURCES = my_module.cc

# Build rules generated by macros from common.mk:

$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
endif

$(eval $(call NMF_RULE,$(TARGET),))

What I have

I tried to reinstall libtocrypt with naclports, but no progress. As I understant my tomcrypt lib built as 32bit but I don't know how to point compiler to make it 64bit.

There is no errors if Makefile is without tomcrypt flag.

I'm not Makefile or C++ pro, but I'm digging there slowly, so it's best to give instructions for me as for newbie on this topics :D


Solution

  • It's been actually a different issue. (I understan dit right after I posted question.. And only now was able to test it).

    Actually I was able to make 64bit .nexe. Problem was with 32bit .nexe. It failed that i couldn't compile them. Error message "skipping incompatible" was given that i tried to find 32bit file but it was 64bit. When I understand that I found similar issue and solution hint.

    Go back to naclports and remove installed libs.

    $ cd naclports/src
    $ ./make_all.sh clean
    

    Edit make_all.sh to compile naclports libs with -m32 flags

    First install g++-multilib to be able to compile 32bit apps. I have ubuntu, so

    sudo apt-get install g++-multilib
    

    Next define flag variables and move # i686 NaCl section to end (so given flags don't break another 64bit sections)

    ...
    export CFLAGS
    export CXXFLAGS
    export LDFLAGS
    
    ...     
    # i686 NaCl
    NACL_ARCH=i686
    TOOLCHAIN=glibc
    CFLAGS="-m32"
    CXXFLAGS="-m32"
    LDFLAGS="-m32"
    make ${TARGETS}
    TOOLCHAIN=newlib
    make ${TARGETS}
    

    Make your libs again

    ./make_all.sh libtomcrypt
    

    Finally make your NaCl module

    Using same Makefile that I copied in question.

    $ cd my_module/
    $ make
      CXX  newlib/Release/my_module_x86_32.o
      LINK newlib/Release/my_module_unstripped_x86_32.nexe
      VALIDATE newlib/Release/my_module_unstripped_x86_32.nexe
      CXX  newlib/Release/my_module_x86_64.o
      LINK newlib/Release/my_module_unstripped_x86_64.nexe
      VALIDATE newlib/Release/my_module_unstripped_x86_64.nexe
      CXX  newlib/Release/my_module_arm.o
      LINK newlib/Release/my_module_unstripped_arm.nexe
      VALIDATE newlib/Release/my_module_unstripped_arm.nexe
      STRIP newlib/Release/my_module_x86_32.nexe
      STRIP newlib/Release/my_module_x86_64.nexe
      STRIP newlib/Release/my_module_arm.nexe
      CREATE_NMF newlib/Release/my_module.nmf
    

    Success!