0

I need to link against a set of libraries in boost.build`. How do I specify the linking order?

This is what I have in the 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
;

It produces a command like:

"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

However, changing the order of libraries executes the command. I can't seem to find a way to specify it in the Jamfile.

Steren
  • 7,311
  • 3
  • 31
  • 51
Humble Debugger
  • 4,439
  • 11
  • 39
  • 56

1 Answers1

0

Reference: The right way to include libraries in boost-build

The solution I found is to load all the static linked libraries as separate rules. I am showing one example here.

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
;

and then change the exe building rule to:

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
    ;
Humble Debugger
  • 4,439
  • 11
  • 39
  • 56