[英]How to link library in C/c++ project in ubuntu 12.04
I tried to install libantlr3c-3.4. 我试图安装libantlr3c-3.4。 When I ran sudo make install, it installed it successfully and gave the following output:
当我运行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'
After which I run make on another project which gives me the following error: 之后,我在另一个项目上运行make,这给了我以下错误:
fatal error: antlr3.h: No such file or directory
I tried to paste the path /opt/open64/lib in /etc/ld.so.conf which then contained the following information: 我试图将路径/ opt / open64 / lib粘贴到/etc/ld.so.conf中,然后包含以下信息:
include /etc/ld.so.conf.d/*.conf
include /opt/open64/lib
I again ran make and again got the same error. 我再次运行make并再次遇到相同的错误。
I am a newbie to C and am new to setting library paths. 我是C的新手,还是设置库路径的新手。 Can someone please guide me as to how should I make my project.
有人可以指导我如何进行我的项目吗?
The procedure which I used for installing libantlr3c-3.4 is: 我用于安装libantlr3c-3.4的过程是:
tar -xzvf libantlr3c-3.4.tar.gz
./configure
make
make install
The compiler doesn't know where the .h is. 编译器不知道.h在哪里。 When you compile, you have to tell it where to look.
编译时,必须告诉它在哪里寻找。 From command line:
从命令行:
gcc -I path_to_where_h_file_lives myFile.cpp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.