我需要链接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中指定它的方法。
答案 0 :(得分:0)
参考: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
;