Changing the order when linking with a Jamfile

When you write a Jamfile and make use of the LINKLIBS variable, take care that the libraries are invoked as last parameters when the compiler is called. Here’s a short example from my current coding work

C++ =  "g++" ;
LINK = "g++" ;
Main eop2nc : eop2nc.cpp  ReadEOP.cpp  WriteEOP.cpp  ;
LINKLIBS on eop2nc$(SUFEXE) = -lnetcdf_c++ -lnetcdf ;

The third line tells Jam to generate an executable named eop2nc, based on the three files. Dependencies are resolved automatically. The critical point for linking under Linux is found in line 4, where it is explicitly stated that libraries are passed AFTER all the other arguments. See this simple explanation for the importance of the link order. Without this line, compilation is done, but linking fails.

Posted in computer, programming

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About commenting on this blog

Since March 2013 commenting is possible for anyone. However, ALL comments will be moderated and since I don't have Internet access 24/7 your comments will be shown a little later.
I take the liberty to reject comments which are against the policy of this blog or violate existing laws.
I appreciate your understanding.

Tag Cloud
Archives
Categories
Visitor map