Opened 17 years ago

Closed 16 years ago

Last modified 10 years ago

#573 closed Support Requests (None)

How to pass CXXFLAGS & LDFLAGS

Reported by: jeffclifford Owned by: nobody
Milestone: Component: Building Boost
Version: None Severity: Problem
Keywords: Cc:

Description

Hi,

I have been trying to build the boost libraries on a
Fedora Core 4 machine.

I want to build a specific gcc334 version of the
libraries that is 64-bit.

I have followed the instructions on the Boost web site
on how to configure boost specifically to pass CXXFLAGS
and LDFLAGS.  I shall run through what I have done:

I am trying to build boost v1.33.1

1)  I cd to BOOST_ROOT/libs/config

2)  I run:  sh ./configure CC=gcc334 CXX=g++334
CXXFLAGS="-m64 -fPIC" LDFLAGS="-m64 -Wl,-rpath
/apps/Linux64/gcc402/lib64 -fPIC"

3)  This creates a user.hpp that I copy to
BOOST_ROOT/boost/config

4)  I cd to BOOST_ROOT

5)  I run:  bjam -sTOOLS=gcc
--builddir=./boost_1_33_1-objdir stage

I then find that any compiler flags that I specified
are simply ignored.  Not only that but checking top I
find that the libraries are being built with the
default compiler instead of the one I specified.

So I then tried the following command instead as the
docs aren't clear what you need to specify to bjam
after doing a specific configuration as above.

bjam -sGCC_ROOT_DIRECTORY=/apps/Linux64/gcc334
-sGCC=gcc334 -sGXX=g++334 -sTOOLS=gcc
--builddir=./boost_1_33_1-objdir stage

This at least makes the correct compiler be used but
still the CXXFLAGS and LDFLAGS are ignored.

I notice there are other posts in this group where
people have asked similar questions.

Surely passing CXXFLAGS and LDFLAGS should be quite a
simple thing to be able to do.

I too am confused by the user.hpp containing the
following which is commented:

//
//  Use this file to define a site and compiler specific
//  configuration policy, this version was
auto-generated by
//  configure on Tue Feb 28 16:06:50 GMT 2006
//  With the following options:
//    CXX      = g++334
//    CXXFLAGS = -I./../.. -I./../../libs/config/test
-m64 -fPIC -DBOOST_NO_CONFIG
//    LDFLAGS  = -m64 -Wl,-rpath
/apps/Linux64/gcc402/lib64 -fPIC
//    LIBS     = -lrt -lm -lpthread 
//

Are these options passed to some other file when the
configure script is run?  They don't seem to be; in
which case is there some macro that holds these values.
 I have checked the docs but can't find a macro
relating to these and checking the gcc.hpp file etc
doesn't give any clues.

I'd be really grateful if anyone can point to what I'm
doing wrong and how I can get my desired build done.

A specific example of how to do this in the boost
documentation would be ideal.

Many thanks,

Jeff Clifford.

Change History (3)

comment:1 by jeffclifford, 17 years ago

Logged In: YES 
user_id=1463920

Well I sorted it myself in the end.  Got lucky with a google
post on how to use -sBUILD option with some other options.

The following worked - note the syntax is for tcsh.

Also needed to specifically specify the lib64 dir with a -L
flag otherwise boost tries to use ther 32-bit lib dir.

There is also some horridness with having to split the
-Wl,-rpath /apps/Linux64/gcc334/lib64 option with two
separate <linkflags> due to the space.

The -d2 flag is useful for seeing the debug output for the
gcc command only.

bjam -sGCC_ROOT_DIRECTORY=/apps/Linux64/gcc334 -sGCC=gcc334
-sGXX=g++334 -sTOOLS=gcc --builddir=./boost_1_33_1-objdir
'-sBUILD=<cxxflags>-m64 <cxxflags>-fPIC <linkflags>-m64
<linkflags>-fPIC <linkflags>-L/apps/Linux64/gcc334/lib64
<linkflags>-Wl,-rpath <linkflags>/apps/Linux64/gcc334/lib64'
-d2 stage

I hope this helps anyone else trying something similar...

Jeff.

comment:2 by René Rivera, 16 years ago

Status: assignedclosed

comment:3 by anonymous, 10 years ago

Severity: Problem
Note: See TracTickets for help on using tickets.