Ubuntu 如何检查g++/铿锵++;默认链接库

Ubuntu 如何检查g++/铿锵++;默认链接库,ubuntu,boost,g++,clang++,Ubuntu,Boost,G++,Clang++,刚刚使用以下命令在Ubuntu 12.04上安装了boost库: sudo apt-get install libboost-all-dev 我使用以下命令编译和构建代码,没有任何问题,即使我没有明确提供所需的boost库 g++ $1.cpp -o $1 -g -Wall -Weffc++ -pedantic -std=c++0x Or clang++ -o $1 -Werror $1.cpp -std=c++11 -O3 #include <iostream> #includ

刚刚使用以下命令在Ubuntu 12.04上安装了boost库:

sudo apt-get install libboost-all-dev
我使用以下命令编译和构建代码,没有任何问题,即使我没有明确提供所需的boost库

g++ $1.cpp -o $1 -g -Wall -Weffc++ -pedantic -std=c++0x
Or
clang++ -o $1 -Werror $1.cpp -std=c++11 -O3

#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp>
#include <string>
using namespace std;

int main()
{
  boost::shared_ptr<int> shpInt(new int(10));

  cout << *shpInt << endl;

  boost::tuple<int, double, std::string> triple(42, 3.14, "my first tuple");
  cout << triple.get<0>() << endl;
  cout << triple.get<1>() << endl;
  cout << triple.get<2>() << endl;
}
g++$1.cpp-o$1-g-Wall-Weffc++-pedantic-std=c++0x
或
clang++-o$1-Werror$1.cpp-std=c++11-O3
#包括
#包括
#包括
#包括
使用名称空间std;
int main()
{
boost::shared_ptr shpInt(新int(10));

cout将-v添加到compile命令行:

g++$1.cpp-o$1-g-Wall-Weffc++-pedantic-std=c++0x-v


然后查找collect2或ld.Clang类似。

这些boost库仅为标题库。没有可提供给链接器的文件。
boost::shared\u ptr
boost::tuple
都不需要链接库,它们是标题库。您可以看到需要链接的库的列表。