繁体   English   中英

如何在Ubuntu 12.04中的C / c ++项目中链接库

[英]How to link library in C/c++ project in ubuntu 12.04

我试图安装libantlr3c-3.4。 当我运行sudo make install时,它成功安装并给出以下输出:

libtool: install: /usr/bin/install -c .libs/libantlr3c.so /opt/open64/lib/libantlr3c.so
libtool: install: /usr/bin/install -c .libs/libantlr3c.lai /opt/open64/lib/libantlr3c.la
libtool: install: /usr/bin/install -c .libs/libantlr3c.a /opt/open64/lib/libantlr3c.a
libtool: install: chmod 644 /opt/open64/lib/libantlr3c.a
libtool: install: ranlib /opt/open64/lib/libantlr3c.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /opt/open64/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /opt/open64/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

之后,我在另一个项目上运行make,这给了我以下错误:

 fatal error: antlr3.h: No such file or directory

我试图将路径/ opt / open64 / lib粘贴到/etc/ld.so.conf中,然后包含以下信息:

include /etc/ld.so.conf.d/*.conf
include /opt/open64/lib

我再次运行make并再次遇到相同的错误。

我是C的新手,还是设置库路径的新手。 有人可以指导我如何进行我的项目吗?

我用于安装libantlr3c-3.4的过程是:

tar -xzvf libantlr3c-3.4.tar.gz
./configure
make 
make install

编译器不知道.h在哪里。 编译时,必须告诉它在哪里寻找。 从命令行:

   gcc -I path_to_where_h_file_lives myFile.cpp

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM