编译bazar包

来源:互联网 发布:苹果机下载不了软件 编辑:程序博客网 时间:2024/05/21 05:23

        这两天在ubuntu下编译bazar包,按照官方给出的安装指南,我首先安装了相应的依赖库(这里省略)。然后,运行 ./configure 。配置生成makefile文件。 再make编译。出现如下的错误信息:


从错误信息可以看出:我们使用了一个库变量,但找不到该变量对应的库链接(动态链接库libopencv_imgproc.so)。但是,令人不解的是:编译命令 g++ -g -o2 -o filedetect ........中明明已经将libopencv_imgproc.so添加了,为什么还会报添加libopencv_imgproc.so到编译命令这样的错误呢?

       在强大的google下搜索: 'cvSmooth' is defined in DSO /usr/local/lib/libopencv_imgproc.so so try adding it to the linker command line  关键字。有幸发现一个帖子(https://lists.fedoraproject.org/pipermail/devel/2010-March/133601.html):


他所述的错误和我遇到的是一个意思。进入链接https://fedoraproject.org/wiki/UnderstandingDSOLinkChange,里面对这种错误作出的解释。The big difference is that with the proposed change in place, ld will no longer skip linking needed libraries by default. The current default behaviour will lead ld to skip linking with a library if it is listed as a needed by another library that the program uses. In abstract terms, if libA is needed by libB and your program requires both libA and libB, your program may only link to libB. Then if another version of libB comes out that does not list libA as a needed library, then a recompilation will mysteriously break.白高兴一场,他这里是没有对libA进行引用,导致出错。而我,引用了,还出错(尼玛。。。)。

        查看makefile文件:

        该有的动态库都有了啊!(这与编译命令一致)。无奈之下,我将/usr/local/lib/libopencv_imgproc.so重复一次,加在最后,编译通过了!!!果断将makefile文件改成:

即,将后面生成的链接库加到opencv库前面。什么意思呢,举个例子:libB要用到libA,即libB依赖libA,编译时,我们需要将被依赖项放到最后。这个在写cmakelists的链接库时遇到过,需要注意一下。

        最后,对所有samples里面的makefile文件改掉,再make,编译通过。注意:不要再去运行./configure了,不然你白改了。


0 0
原创粉丝点击