PNaCl & gtest—pnacl-ld:不兼容的目标文件 (X8664 != X8632)

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

我是这方面的新手,请帮助我...T_T...

最近我正在用 ninja[=85= 构建 pthreadpoolNNPACK 需要) ] 在我的 Ubuntu 14.04 64 位上。 它需要Google PNaCl(Portable Native Client)Google测试,我都安装了。

在我 运行 python ./configure.py 之后,在 pthreadpool root 目录中, 它生成了一个文件 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

但是当我运行命令ninja时,出现了错误:

[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.

我认为可能是路径问题,所以我把libgtest.alibgtest_main.a(生成来自 Google 测试)在 /usr/lib/gtest 并修改了 build.ninja:

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

ninja 似乎找到了 lib 文件,但出现了错误:

[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.

我相信 lib 文件是好的,因为我尝试使用 g++ 编译 test.cpp:

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

它奏效了。

所以我认为 pnacl 或我使用的方式可能有问题 it.I 用谷歌搜索了关于 pnacl 和 gtest 的 32 位 64 位不兼容问题,但我什么也没得到。现在我完全不知道该怎么做,因为我是这方面的新手...

所以,如果有任何帮助、想法或建议,我们将不胜感激!

对于 Google PNaCl,我下载了 nacl_sdk.zip 并将其解压缩到 /home/rokim/nacl_sdk,我得到了 sdk_toolspepper_49 最新。

为了Google测试,我运行sudo apt-get install libgtest-devcmakemake 我得到 libgtest.alibgtest_main.a 然后我将它们放入 /usr/lib 和 /usr/local/lib。gtest 包含文件放入 /usr/include 和 usr/local/include。

您不能将来自主机系统的 libgtest 与 NaCl 编译器一起使用。 link 必须使用相同的 (NaCl) 编译器构建所有内容。所以你想用 pnacl-clang 构建 libgtest,link 用你的其他 PNaCl 构建。