1

我使用的是 OpenCV,但由于某种原因需要重新安装它!但是我的程序现在无法编译!我的编译脚本是:

#!/bin/sh
if [ $# -gt 0 ] ; then
#   base=`basename $1 .c`
#   echo "compiling $base"
#   gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base 

#   base=`basename $1 .cpp`
    echo "compiling $1"
    g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `pkg-config --libs opencv`;
#   gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base 

else
    for i in *.c; do
        echo "compiling $i"
        gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
    done
    for i in *.cpp; do
        echo "compiling $i"
        g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
    done
fi

当我像./build_all.sh test10Camera.cpp它不起作用一样使用它时,输出和错误是:

compiling test10Camera.cpp
/usr/bin/ld: warning: libtbb.so, needed by /usr/local/lib/libopencv_core.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_scheduler_init::initialize(int)'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task::note_affinity(unsigned short)'
/usr/local/lib/libopencv_imgproc.so: undefined reference to `tbb::internal::handle_perror(int, char const*)'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned int) const'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_scheduler_init::terminate()'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
/usr/local/lib/libopencv_core.so: undefined reference to `typeinfo for tbb::task'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned int) const'
/usr/local/lib/libopencv_core.so: undefined reference to `vtable for tbb::task'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_group_context::init()'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_scheduler_init::default_num_threads()'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::task_group_context::~task_group_context()'
/usr/local/lib/libopencv_core.so: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned int) const'
collect2: ld returned 1 exit status

出了什么问题,我该怎么办?

4

1 回答 1

3

错误消息准确地告诉您出了什么问题:

/usr/bin/ld: warning: libtbb.so, needed by /usr/local/lib/libopencv_core.so, not found (try using -rpath or -rpath-link)

去获取libtbb并安装它,或者如果你已经有了,确保你的编译器知道在哪里可以找到它。

于 2013-09-12T04:29:46.297 回答