Menu

#205 VisualAge linker fails for shared libraries

closed-fixed
cpptasks (103)
5
2015-01-04
2007-05-10
Anonymous
No

When compiling shared libraries on AIX (using the Visual Age compiler), the following error is produced when linking:

[aix] 62 % ant
Buildfile: build.xml

build:
[cpp:cc] 1 total files to be compiled.
[cpp:cc] Starting link
[cpp:cc] /usr/vacpp/bin/makeC++SharedLib: 1543-301 Priority must be specified

BUILD FAILED
/home/darius42/tmp2/build.xml:7: makeC++SharedLib failed with return code 3

Total time: 2 seconds
[aix] 63 %

build.xml:
----
<project
name="foo"
default="build"
xmlns:cpp="antlib:net.sf.antcontrib.cpptasks">

<target name="build">
<cpp:cc outfile="foo" outtype="shared">
<cpp:compiler name="xlC"/>
<cpp:linker name="xlC"/>
<cpp:fileset dir=".">
<include name="file.cpp"/>
</cpp:fileset>
</cpp:cc>
</target>
</project>

file.cpp
----
int foo(void) {
return 0;
}

Discussion

  • David Haney

    David Haney - 2007-05-10

    Logged In: YES
    user_id=1140024
    Originator: NO

    I accidentally submitted without verifying I was logged in. Adding a comment to associate this issue with my user account.

     
  • David Haney

    David Haney - 2007-05-10

    Logged In: YES
    user_id=1140024
    Originator: NO

    As a part of investigating this failure, I ran across the following IBM documentation indicating that makeC++SharedLib is no longer the recommended method for creating shared libraries on AIX:

    http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.xlcpp8a.doc/proguide/ref/rkmkslib.htm

    Instead, users should use the xlC compiler with the -qmkshrobj flag.

    After addressing that issue, the linker failed indicating that the -Bdynamic and -Bstatic flags aren't valid with xlC, and instead users should specify -bdynamic and -bstatic respectively. Since these flags are specified at a higher level (in gcc/AbstractLdLinker.java), it was necessary to add hooks to that class that would allow overriding these strings in derived classes.

    Finally, I modified the suffix associated with generated libraries from .so to .a. While .so is supported on AIX, .a (shared archive) still appears to be the dominant suffix for must of the projects I surveyed.

     
  • David Haney

    David Haney - 2007-05-10

    Logged In: YES
    user_id=1140024
    Originator: NO

    The following is a diff with the associated changes to address this issue (I'm unable to attach a file, presumably because I'm not listed in the "Submitted By" or "Assigned To" lists).

    Index: src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java

    --- src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java (revision 118)
    +++ src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java (working copy)
    @@ -115,13 +115,13 @@
    //
    if (set.getType() != previousLibraryType) {
    if (set.getType() != null && "static".equals(set.getType().getValue())) {
    - endargs.addElement("-Bstatic");
    + endargs.addElement(getStaticLibFlag());
    previousLibraryType = set.getType();
    } else {
    if (set.getType() == null ||
    !"framework".equals(set.getType().getValue()) ||
    !isDarwin()) {
    - endargs.addElement("-Bdynamic");
    + endargs.addElement(getDynamicLibFlag());
    previousLibraryType = set.getType();
    }
    }
    @@ -322,4 +322,12 @@
    return super.prepareArguments(task, outputDir, outputFile,
    finalSources, config);
    }
    +
    + protected String getDynamicLibFlag() {
    + return "-Bdynamic";
    + }
    +
    + protected String getStaticLibFlag() {
    + return "-Bstatic";
    + }
    }
    Index: src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java
    ===================================================================
    --- src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java (revision 118)
    +++ src/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java (working copy)
    @@ -31,7 +31,7 @@

    private static final String[] objFiles = new String[]{".o", ".a", ".lib",
    ".dll", ".so", ".sl"};
    private static final VisualAgeLinker dllLinker = new VisualAgeLinker(
    - "makeC++SharedLib", objFiles, discardFiles, "lib", ".so");
    + "xlC", objFiles, discardFiles, "lib", ".a");
    private static final VisualAgeLinker instance = new VisualAgeLinker("xlC",
    objFiles, discardFiles, "", "");
    public static VisualAgeLinker getInstance() {
    @@ -50,7 +50,7 @@

    //args.addElement("-g");
    }
    if (linkType.isSharedLibrary()) {
    - //args.addElement("-G");
    + args.addElement("-qmkshrobj");
    }
    }
    public Linker getLinker(LinkType type) {
    @@ -69,7 +69,15 @@

    * would lock up. Using a stock response.
    */
    public String getIdentifier() {
    - return "VisualAge linker - unidentified version";
    + return "VisualAge linker - unidentified version";
    }
    +
    + protected String getDynamicLibFlag() {
    + return "-bdynamic";
    + }
    +
    + protected String getStaticLibFlag() {
    + return "-bstatic";
    + }

    }

     
  • Curt Arnold

    Curt Arnold - 2007-05-11

    Logged In: YES
    user_id=27193
    Originator: NO

    Patch looks reasonable. Adding you as a developer to the project, feel free to commit this one.

     
  • David Haney

    David Haney - 2007-05-13

    Logged In: YES
    user_id=1140024
    Originator: NO

    This was committed in revision 119.

     
  • David Haney

    David Haney - 2007-08-22
    • assigned_to: carnold --> darius42
    • status: open --> closed-fixed
     

Log in to post a comment.