【问题标题】:How do I specify dependencies in libraries in Jamfiles?如何在 Jamfiles 的库中指定依赖项?
【发布时间】:2017-04-16 00:59:33
【问题描述】:

我需要链接 boost.build 中的一组库。如何指定链接顺序?

这就是我在 Jamfile 中的内容。

exe sim_strategy
: sim_strategy.cpp 
:
<linkflags>-lOptionsUtils 
  <linkflags>-lVolatileTradingInfo 
  <linkflags>-lCommonTradeUtils 
  <linkflags>-lBaseUtils
  <linkflags>-lTradingInfo 
  <linkflags>-lTradeUtils 
  <linkflags>-lExternalData 
  <linkflags>-lMarketAdapter 
  <linkflags>-lOrderRouting 
  <linkflags>-lSmartOrderRouting 
  <linkflags>-lInitCommon 
  <linkflags>-lExecLogic
  <linkflags>-lRiskManagement
  <linkflags>-lOptionsUtils
  <linkflags>-lModelMath 
  <linkflags>-lORSMessages
  <linkflags>-lProfiler
: <variant>debug <variant>release
;

它产生如下命令:

"g++" -L"/apps/bzip2/lib" -L"/home/gchak/boost-try/boost-install/lib" -L"/home/gchak/cvquant/basetrade_install/lib"   -o "InitLogic/bin/gcc-6.3.0/release/link-static/sim_strategy" -Wl,--start-group "InitLogic/bin/gcc-6.3.0/release/link-static/sim_strategy.o" "/home/gchak/cvquant/basetrade_install/lib/libSimPnls.a" "/home/gchak/cvquant/basetrade_install/lib/libSimMarketMaker.a" "/home/gchak/cvquant/basetrade_install/lib/libLoggedSources.a"  -Wl,-Bstatic  -Wl,-Bdynamic  -Wl,--end-group  -lBaseUtils -lCDef -lCommonDataStructures -lCommonTradeUtils -lExecLogic -lExternalData -lIndicators -lInitCommon -lMarketAdapter -lModelMath -lORSMessages -lOptionsUtils -lOrderRouting -lProfiler -lRiskManagement -lSmartOrderRouting -lTradeUtils -lTradingInfo -lUtils -lVolatileTradingInfo -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_system -lcrypto -lcurl -lz

但是,更改库的顺序会执行命令。我似乎找不到在 Jamfile 中指定它的方法。

【问题讨论】:

    标签: c++ bjam boost-build jam


    【解决方案1】:

    参考:The right way to include libraries in boost-build

    我找到的解决方案是将所有静态链接库作为单独的规则加载。我在这里展示一个例子。

    lib OptionsUtils
    : # no sources
    : # requirements
    <name>OptionsUtils $(dvccode-lib-search-path)
    <use>CommonDataStructures <use>CDef
    : # build arguments - none needed
    : # usage requirements - this specifies other libraries that should be included before this
    <library>CDef <library>CommonDataStructures
    ;
    

    然后将exe构建规则改为:

    use-project /PDVCC : ../libdvccode ;
    
    exe sim_strategy
        : 
          sim_strategy.cpp
          /PDVCC//OptionsUtils 
          /PDVCC//ModelMath 
          /PDVCC//ExternalData 
          /PDVCC//CommonTradeUtils
          /PDVCC//MarketAdapter 
          /PDVCC//InitCommon
          /PDVCC//ExecLogic
          /PDVCC//Profiler
          /PDVCC//OrderRouting
          /PDVCC//TradeUtils
          /PDVCC//TradingInfo
          /PDVCC//SmartOrderRouting
          /PDVCC//RiskManagement
          /PDVCC//RiskManager
          /PDVCC//VolatileTradingInfo
        :
        : <variant>debug <variant>release
        ;
    

    【讨论】:

    • 参考链接目前已失效。
    猜你喜欢
    • 2015-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-11
    • 1970-01-01
    • 2010-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多