未找到-lboost_system库 [英] library not found for -lboost_system

查看:206
本文介绍了未找到-lboost_system库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MacPorts使用安装提振。这些文件似乎是在/ opt /本地/包括/升压/

I installed boost using macports. The files appear to be in /opt/local/include/boost/

我的makefile不再工作,我得到了以下错误

My makefile is no longer working and I get the following error

Undefined symbols:
"boost::system::generic_category()", referenced from:
  __static_initialization_and_destruction_0(int, int)in client.o
  __static_initialization_and_destruction_0(int, int)in client.o
"boost::system::system_category()", referenced from:
  boost::asio::error::get_system_category()    in client.o
  boost::system::error_code::error_code()in client.o
  __static_initialization_and_destruction_0(int, int)in client.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [client] Error 1

在学校的解决方案是使用-lboost_system作为参数传递给G ++,但现在我已经采取了该项目的主页我的Mac,这是行不通的。我认为这主要是由于这一事实,即在学校升压文件是在USR / local / lib目录(或类似的地方)。

at school the solution was to use -lboost_system as an argument to g++, but now that I've taken the project home to my mac, this does not work. I think this is mostly due to the fact that at school the boost files were at usr/local/lib (or somewhere similar).

当我添加了-lboost_system说法我得到以下信息

When I add the -lboost_system argument i get the following message

g++ -I/opt/local/include -lboost_system -o client client.o Packet.o
ld: library not found for -lboost_system
collect2: ld returned 1 exit status
make: *** [client] Error 1

我已经使用-L和-l尝试了一些变化,但我似乎无法找到一个可行的组合。在学校里我也没有使用-L。我在这里读了几其他职位有关类似的问题,但他们通过添加的arent为我工作-l标志固定它。

I've tried a few variations using -L and -l, but I can't seem to find a combo that works. At school I also do not have to use -L. I've read a few other posts here about similar problems, but they fixed it by adding -l flags which arent working for me.

帮助!谢谢!

推荐答案

您错过一个 -L /选择/ local / lib目录。您应该能够设置 LDFLAGS 在Makefile:

You're missing a -L/opt/local/lib. You should be able to set the LDFLAGS in your Makefile:

LDFLAGS=-L/opt/local/lib

这假定Boost库是当然的的/ opt / local / lib目录

This assumes that the Boost libraries are in /opt/local/lib of course.

如果你不使用通常的 CXXFLAGS LDFLAGS 在Makefile变量,然后添加 -L /选择/ local / lib目录直接在最终规则:

If you're not using the usual CXXFLAGS and LDFLAGS variables in your Makefile, then add the -L/opt/local/lib directly in your final rule:

client: client.o Packet.o
    g++ -L/opt/local/lib -o client client.o Packet.o -lboost_system

-I 只告诉编译器在哪里头文件,链接器需要的库,并使用 -L

The -I only tells the compiler where header files are, the linker needs libraries and you use -L for that.

这篇关于未找到-lboost_system库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆