Link order is important when building executables

RESOLVED FIXED

Status

Directory
LDAP C SDK
RESOLVED FIXED
12 years ago
12 years ago

People

(Reporter: Rich Megginson, Assigned: mcs)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

12 years ago
The order of items to link is important on some platforms when building the executables for the command line tools.  They must be in order of dependency.  Something like this:
.o files -> -lssldap -> -lprldap -> -lldap -> -lsvrcore -> nss libs -> nspr libs -> system libs

Otherwise you get weird link errors.  Also, the makefile.in for tools is kind of messy and redundant.
(Reporter)

Comment 1

12 years ago
Created attachment 208278 [details]
list of files for fix
(Reporter)

Comment 2

12 years ago
Created attachment 208279 [details]
diffs for fix
(Reporter)

Comment 3

12 years ago
The LINK_EXE macro already has everything needed - it is not necessary to supply extra libs in the form of the LDTOOLS_LIBS.  Just specify them in the correct order in EXTRA_LIBS.  You don't need to set EXTRA_LIBS for every platform - on *nix platforms, they are all the same, so just define them in a common place in the correct order.  Use PLATFORMLIBS to specify platform dependent libs.

The one tricky thing is that LINK_EXE expects OBJS to have all of the objects.  This works if you only build one executable per makefile, but this makefile builds several, so you need to get the executable specific .obj file in the link line as well.  I suppose I could have used target specific variable assignment to OBJS, but that seemed messy to me, so I just added a $(filter ..) to the LINK_EXE command which will add all of the .obj files specified in the executable link target dependency list to the link line.  The filter is to filter out libraries and other dependencies, which are usually specified elsewhere.  This seems to work on linux x86_64 and HP IPF 64 just fine.
(Reporter)

Comment 4

12 years ago
Checking in mozilla/directory/c-sdk/build.mk;
/cvsroot/mozilla/directory/c-sdk/build.mk,v  <--  build.mk
new revision: 5.24; previous revision: 5.23
done
Checking in mozilla/directory/c-sdk/configure;
/cvsroot/mozilla/directory/c-sdk/configure,v  <--  configure
new revision: 5.39; previous revision: 5.38
done
Checking in mozilla/directory/c-sdk/configure.in;
/cvsroot/mozilla/directory/c-sdk/configure.in,v  <--  configure.in
new revision: 5.40; previous revision: 5.39
done
Checking in mozilla/directory/c-sdk/ldap/clients/tools/Makefile.in;
/cvsroot/mozilla/directory/c-sdk/ldap/clients/tools/Makefile.in,v  <--  Makefile.in
new revision: 5.11; previous revision: 5.10
done
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.