【问题标题】:Compilation issue while using Folly Futures使用 Folly Futures 时的编译问题
【发布时间】:2016-06-21 08:47:12
【问题描述】:
#include <folly/futures/Future.h>
#include<iostream>
using namespace folly;
using namespace std;

void foo(int x) 
{
  // do something with x
  cout << "foo(" << x << ")" << endl;
}
// ...
int main()
{ 
  cout << "making Promise" << endl;
  Promise<int> p;
  Future<int> f = p.getFuture();
  return 0;
}

LD_LIBRARY_PATH 设置为 /usr/local/lib

当我编译时,使用

g++ -std=c++11 sample.cpp -pthread  -llzma -lz -lsnappy -llz4 -liberty \
    -ljemalloc -levent -ldouble-conversion -lssl -lgflags -lglog -lboost_system

我收到此错误消息:

/tmp/ccuDCM19.o: In function `main':
sample.cpp:(.text+0x1a7): undefined reference to `folly::Future<int>::~Future()'
/tmp/ccuDCM19.o: In function `folly::RequestContext::setContext(std::shared_ptr<folly::RequestContext>)':
sample.cpp:(.text._ZN5folly14RequestContext10setContextESt10shared_ptrIS0_E[_ZN5folly14RequestContext10setContextESt10shared_ptrIS0_E]+0x11): undefined reference to `folly::RequestContext::getStaticContext()'
/tmp/ccuDCM19.o: In function `folly::Promise<int>::getFuture()':
sample.cpp:(.text._ZN5folly7PromiseIiE9getFutureEv[_ZN5folly7PromiseIiE9getFutureEv]+0x36): undefined reference to `folly::Future<int>::Future(folly::detail::Core<int>*)'
collect2: error: ld returned 1 exit status

【问题讨论】:

    标签: c++ ld folly


    【解决方案1】:

    问题通过添加 -lolly 得到解决。

    【讨论】:

    • 在哪里?如何?你能说得更具体一点吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 2015-04-27
    • 2020-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多