0

刚刚使用以下命令在 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++ 或 clang++ 使用的默认链接库?

谢谢

4

1 回答 1

0

将 -v 添加到编译命令行:

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

然后寻找 collect2 或 ld。Clang 是类似的。

于 2013-07-08T15:33:00.230 回答