linuxubuntugoogletestgoogle-nativeclientninja

PNaCl & gtest—pnacl-ld: Incompatible object file (X8664 != X8632)


I'm a newbie at this,Please help me ...T_T...

Recently I was building pthreadpool(required by NNPACK) with ninja on my Ubuntu 14.04 64bit. It requires Google PNaCl(Portable Native Client) and Google Test,and I installed both.

After I run python ./configure.py in pthreadpool root dir, it generated a file build.ninja:

pnacl_toolchain_dir = $nacl_sdk_dir/toolchain/linux_pnacl
pnacl_cc = $pnacl_toolchain_dir/bin/pnacl-clang
pnacl_cxx = $pnacl_toolchain_dir/bin/pnacl-clang++
pnacl_ar = $pnacl_toolchain_dir/bin/pnacl-ar
pnacl_finalize = $pnacl_toolchain_dir/bin/pnacl-finalize
pnacl_translate = $pnacl_toolchain_dir/bin/pnacl-translate
pnacl_sel_ldr = $nacl_sdk_dir/tools/sel_ldr.py
cflags = -std=gnu11
cxxflags = -std=gnu++11
optflags = -O3
rule cc
  command = $pnacl_cc -o $out -c $in -MMD -MF $out.d $optflags $cflags $
      $includes
  description = CC[PNaCl] $descpath
  depfile = $out.d
  deps = gcc
rule cxx
  command = $pnacl_cxx -o $out -c $in -MMD -MF $out.d $optflags $cxxflags $
      $includes
  description = CXX[PNaCl] $descpath
  depfile = $out.d
  deps = gcc
rule ccld
  command = $pnacl_cc -o $out $in $libs $libdirs $ldflags
  description = CCLD[PNaCl] $descpath
rule cxxld
  command = $pnacl_cxx -o $out $in $libs $libdirs $ldflags
  description = CXXLD[PNaCl] $descpath
rule ar
  command = $pnacl_ar rcs $out $in
  description = AR[PNaCl] $descpath
rule finalize
  command = $pnacl_finalize $finflags -o $out $in
  description = FINALIZE[PNaCl] $descpath
rule translate
  command = $pnacl_translate -arch $arch -o $out $in
  description = TRANSLATE[PNaCl] $descpath
rule run
  command = $pnacl_sel_ldr $in
  description = RUN[PNaCl] $descpath
  pool = console
rule install
  command = install -m $mode $in $out
  description = INSTALL $out
build /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc: cc $
    /home/rokim/NNPACK/third-party/pthreadpool/src/pthreadpool.c
  descpath = pthreadpool.c
  includes = -I$nacl_sdk_dir/include $
      -I/home/rokim/NNPACK/third-party/pthreadpool/include $
      -I/home/rokim/NNPACK/third-party/pthreadpool/src
build $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/libpthreadpool.a: $
    ar /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc
  descpath = libpthreadpool.a
build $
    /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.cc.bc: $
    cxx /home/rokim/NNPACK/third-party/pthreadpool/test/pthreadpool.cc
  descpath = pthreadpool.cc
  includes = -I$nacl_sdk_dir/include $
      -I/home/rokim/NNPACK/third-party/pthreadpool/include $
      -I/home/rokim/NNPACK/third-party/pthreadpool/src
build /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc: $
    cxxld /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc $
    /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.cc.bc
  libs = -lgtest
  libdirs = -L$nacl_sdk_dir/lib/pnacl/Release
  descpath = pthreadpool.bc
build $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/pthreadpool.pexe: $
    finalize $
    /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc
  descpath = pthreadpool.pexe
build $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/pthreadpool.nexe: $
    translate $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/pthreadpool.pexe
  arch = x86_64
  descpath = pthreadpool.pexe
build test: run $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/pthreadpool.nexe
  descpath = pthreadpool.nexe
default $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/libpthreadpool.a $
    /home/rokim/NNPACK/third-party/pthreadpool/artifacts/pthreadpool.nexe
build /usr/local/include/pthreadpool.h: install $
    /home/rokim/NNPACK/third-party/pthreadpool/include/pthreadpool.h
  mode = 0644
build /usr/local/lib/libpthreadpool.a: install $
    /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc
  mode = 0644
build install: phony /usr/local/include/pthreadpool.h $
    /usr/local/lib/libpthreadpool.a

But when I run the command ninja,there came the error:

[4/6] CXXLD[PNaCl] pthreadpool.bc
FAILED: /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc 
/toolchain/linux_pnacl/bin/pnacl-clang++ -o /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.cc.bc -lgtest -L/lib/pnacl/Release 
pnacl-ld: Cannot find '-lgtest'
ninja: build stopped: subcommand failed.

I thought it may be the path problem,so I put libgtest.a and libgtest_main.a (Generated from Google Test) in /usr/lib/gtest and modified the build.ninja:

libs = -L/usr/lib/gtest -lgtest_main -lgtest

It seems ninja found the lib files, but there came the error:

[1/3] CXXLD[PNaCl] pthreadpool.bc
FAILED: /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc 
/toolchain/linux_pnacl/bin/pnacl-clang++ -o /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.bc /home/rokim/NNPACK/third-party/pthreadpool/build/pthreadpool.c.bc /home/rokim/NNPACK/third-party/pthreadpool/build/test/pthreadpool.cc.bc -L/usr/lib/gtest -lgtest_main -lgtest -L/lib/pnacl/Release 
pnacl-ld: /usr/lib/gtest/libgtest_main.a: Incompatible object file (X8664 != X8632)
ninja: build stopped: subcommand failed.

I believe the lib files are good since I tried to use g++ to compile a test.cpp:

g++ test.cpp -lgtest_main -lgtest -lpthread

And it worked.

So I thought it might be something wrong about pnacl or the way I use it.I googled the 32bit 64bit incompatible problem about pnacl and gtest but I got nothing. Now I have totally no idea about what to do since I'm a newbie at this...

So please, any help, idea or suggestions would be greatly appriciate!

For Google PNaCl,I downloaded the nacl_sdk.zip and unziped it to /home/rokim/nacl_sdk and I got sdk_tools and pepper_49 up to date.

For Google Test,I run sudo apt-get install libgtest-dev . After cmake and make I got libgtest.a and libgtest_main.a then I put them into /usr/lib and /usr/local/lib.The gtest include file are put into /usr/include and usr/local/include.


Solution

  • You can't use libgtest from the host system with the NaCl compilers. Everything you link has to be built with the same (NaCl) compiler. So you want to build libgtest with pnacl-clang, and link that with your other PNaCl build.