我是新手,请帮助我...... T_T ......
最近我在我的Ubuntu 14.04 64位上使用 ninja 构建了 pthreadpool ( NNPACK 所需)。 它需要 Google PNaCl(Portable Native Client) 和 Google测试,我安装了两者。
在pthreadpool root dir中运行 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.a 和 libgtest_main.a (由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_tools 和 pepper_49 最新版。
对于Google Test,我运行 sudo apt-get install libgtest-dev 。在 cmake 和 make 之后,我得到 libgtest.a 和 libgtest_main.a ,然后我将它们放入/ usr / lib和/usr/local/lib.gtest包含文件放入/ usr / include和usr / local / include。
答案 0 :(得分:0)
您不能在主机系统中使用带有NaCl编译器的libgtest。您链接的所有内容都必须使用相同的(NaCl)编译器构建。所以你想用pnacl-clang构建libgtest,并将它与你的其他PNaCl构建链接起来。