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

Posted

技术标签:

【中文标题】PNaCl & gtest—pnacl-ld: 不兼容的目标文件 (X8664 != X8632)【英文标题】:PNaCl & gtest—pnacl-ld: Incompatible object file (X8664 != X8632) 【发布时间】:2016-11-28 07:44:48 【问题描述】:

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

最近我在 Ubuntu 14.04 64 位上使用 ninja 构建 pthreadpoolNNPACK 需要)。 它需要 Google PNaCl(Portable Native Client)Google Test,我都安装了。

在 pthreadpool 根目录中运行 python ./configure.py 后, 它生成了一个文件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 (Generated from Google Test) 放在 /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 或我使用它的方式可能有问题。我在谷歌上搜索了关于 pnacl 和 gtest 的 32 位 64 位不兼容问题,但我一无所获。现在我完全不知道该怎么做,因为我是这方面的新手......

所以请,任何帮助、想法或建议都会非常感谢!

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

对于 Google 测试,我运行 sudo apt-get install libgtest-dev 。在 cmakemake 我得到 libgtest.alibgtest_main.a 然后我把它们放到 /usr/lib和/usr/local/lib。gtest的包含文件放在/usr/include和usr/local/include中。

【问题讨论】:

【参考方案1】:

您不能将主机系统中的 libgtest 与 NaCl 编译器一起使用。您链接的所有内容都必须使用相同的 (NaCl) 编译器构建。因此,您想使用 pnacl-clang 构建 libgtest,并将其与您的其他 PNaCl 构建链接。

【讨论】:

谢谢你!!!我修改了 cmakelist 以使用 pnacl-clang 编译 gtest,它现在可以工作了!非常感谢! ^_^

以上是关于PNaCl & gtest—pnacl-ld: 不兼容的目标文件 (X8664 != X8632)的主要内容,如果未能解决你的问题,请参考以下文章

gtest&gcovr&ccn

如何在 PNaCl 中等待 WebSocket 响应

PNaCl - 编译错误“仅支持 Win32 目标”

linux gtest安装

Chrome 的 PNaCl 还活着么?

PNaCl 再见,WebAssembly 你好!