如何在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
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 无法在 CLion 中构建 C++ 项目
- 运行同一解决方案的另一个项目的项目
- CMake-按正确顺序将项目与C运行时对象文件链接
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 欧拉项目#8答案是大以获得有效答案
- 从链接列表c++中删除一个项目
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 既然存在危险,为什么项目要使用-I include开关
- cmake在我的项目中所需的所有静态库都不成功
- QT通过C++添加映射QML项目
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在linux上调试巨大的C++项目
- 在其他文件中创建类时在 c++ 项目中不起作用
- 使外部项目可用于find_package CMake
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- 如何维护资源管理器项目视图中当前可见的项目列表
- 错误-我无法在VS2019中打开新的Qt项目
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗