我是这方面的新手,请帮帮我。。。
最近我在我的Ubuntu 14.0464bit上用忍者构建pthreadpool(NNPACK要求)。
它需要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
但当我运行忍者命令时,出现了一个错误:
[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.
我认为这可能是路径问题,所以我将lib gtest.a和libgtest_main.a(从Google Test生成)放在/usr/lib/gtest中,并修改了build.ninja:
libs = -L/usr/lib/gtest -lgtest_main -lgtest
似乎忍者找到了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_工具和pepper_49。
对于Google测试,我运行sudo apt get install libgtest dev。在cmake并使我得到lib gtest.a和libgtest_main.a之后,我将它们放入/usr/lib和/usr/local/lib中,gtest include文件放入/usr/include和usr/local/include中。
最佳答案
不能将主机系统中的libgtest与NaCl编译器一起使用。链接的所有内容都必须使用相同的(NaCl)编译器构建。所以您想用pnacl clang构建libgtest,并将其与其他pnacl构建链接起来。