logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derek Baum <derek.b...@paremus.com>
Subject Re: ant build problem.
Date Thu, 12 Oct 2006 10:25:12 GMT
This error is because gcc rather than g++ is being used for the link.

This is because the compiler setting on line 229 of build.xml takes 
precedence over the one on line 235:
>     227 <target name="unix-init" depends="mac-init" if="is-unix">
>     228
>     229     <property name="compiler" value="gcc"/>
>     230
>     231     <property name="lib.prefix" value="lib"/>
>     232     <property name="lib.extension" value=".a"/>
>     233     <property name="project.type" value="cbuilderx"/>
>     234     <property name="project.dir" value="cbx"/>
>     235     <property name="compiler" value="g++"/>
>     236     <property name="lib-suffix" value=""/>
However, simply removing the offending compiler setting on line 229, 
does not fix the problem.
"ant -v" shows why - cpptasks is still using gcc to link!
>        [cc] Starting link
>        [cc] gcc -g -prebind -dynamiclib -o liblog4cxx.dylib 
> log4cxx_obj/socket.o ...
>  -laprutil-1 -L/Users/derek/src/svn-log4cxx/build/debug/static -lapr-1 
> -liconv -lpthread -lstdc++
>        [cc] ld: warning -prebind ignored because 
> MACOSX_DEPLOYMENT_TARGET environment variable greater or equal to 10.4
>        [cc] ld: Undefined symbols:
>        [cc] __Unwind_Resume
>        [cc] /usr/bin/libtool: internal link edit command failed
I think this is a bug in cpptasks-1.04b which the following changes 
appear to fix:
> --- src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java        
> 2006-05-19 13:48:38.000000000 +0100
> +++ 
> /Users/derek/src/cpptasks-1.0b4/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
       
> 2006-10-12 10:19:06.000000000 +0100
> @@ -234,6 +234,10 @@
>          return identifier;
>      }
>      public Linker getLinker(LinkType linkType) {
> +       // derek.baum@paremus.com - return gpp linker
> +       if (getCommand().equals("g++")) {
> +           return GppLinker.getInstance().getLinker(linkType);
> +       }
>          return GccLinker.getInstance().getLinker(linkType);
>      }
>      public int getMaximumCommandLength() {

> --- src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java   2006-05-19 
> 13:48:38.000000000 +0100
> +++ 
> /Users/derek/src/cpptasks-1.0b4/src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java   
> 2006-10-12 10:21:10.000000000 +0100
> @@ -29,12 +29,13 @@
>   *
>   * @author Stephen M. Webb <stephen.webb@bregmasoft.com>
>   */
> +// derek.baum@paremus.com - use use "g++" for GppLinker
>  public class GppLinker extends AbstractLdLinker {
>      protected static final String[] discardFiles = new String[0];
>      protected static final String[] objFiles = new String[]{".o", 
> ".a", ".lib",             ".dll", ".so", ".sl"};
> -    private static final GppLinker dllLinker = new GppLinker("gcc", 
> objFiles,
> -            discardFiles, "lib", ".so", false, new GppLinker("gcc", 
> objFiles,
> +    private static final GppLinker dllLinker = new GppLinker("g++", 
> objFiles,
> +            discardFiles, "lib", ".so", false, new GppLinker("g++", 
> objFiles,
>                      discardFiles, "lib", ".so", true, null));
>      private final static String libPrefix = "libraries: =";
>      protected static final String[] libtoolObjFiles = new 
> String[]{".fo", ".a",@@ -42,11 +43,11 @@
>      private static String[] linkerOptions = new String[]{"-bundle", 
> "-dylib",
>              "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
>              "-prebind", "-s", "-static", "-shared", "-symbolic", 
> "-Xlinker"};
> -    private static final GppLinker instance = new GppLinker("gcc", 
> objFiles,
> +    private static final GppLinker instance = new GppLinker("g++", 
> objFiles,
>              discardFiles, "", "", false, null);
> -    private static final GppLinker machDllLinker = new GppLinker("gcc",
> +    private static final GppLinker machDllLinker = new GppLinker("g++",
>              objFiles, discardFiles, "lib", ".dylib", false, null);
> -    private static final GppLinker machPluginLinker = new 
> GppLinker("gcc",
> +    private static final GppLinker machPluginLinker = new 
> GppLinker("g++",
>              objFiles, discardFiles, "lib", ".bundle", false, null);
>      public static GppLinker getInstance() {
>          return instance;

The next problem you'll encounter is:

> build-shortsocketserver:
>        [cc] Starting dependency analysis for 1 files.
>        [cc] 1 files are up to date.
>        [cc] 0 files to be recompiled from dependency analysis.
>        [cc] 0 total files to be compiled.
>        [cc] Starting link
>        [cc] /usr/bin/ld: can't locate file for: -llog4cxx
>        [cc] collect2: ld returned 1 exit status

This is because the log4cxx shared library was built with a .so 
extension, rather than .dylib.
I build log4cxx static, so I haven't fixed this yet (you can always 
manually rename it).

The build and all unit tests then complete successfully, however you're 
not quite done, because a clean build will now fail to compile apr:

> BUILD FAILED
> /Users/derek/src/svn-log4cxx/build.xml:553: The following error 
> occurred while executing this line:
> /Users/derek/src/svn-log4cxx/apr-build.xml:166: g++ failed with return 
> code 1
This is because the changes made to use the g++ linker, also cause g++ 
to be used to compile apr.
So I added an apr-compiler property into build.xml:

> --- build.xml   (revision 463159)
> +++ build.xml   (working copy)
> @@ -62,7 +62,7 @@
>  <property name="version" value="0.10.0"/>
>  <property name="rtti" value="false"/>
>  <property name="optimize" value="none"/>
> -<property name="lib.type" value="shared"/>
> +<property name="lib.type" value="static"/>
>  <property name="has.wchar_t" value="1"/>
>  
>  <property name="apache.mirror" value="http://archive.apache.org/dist"/>
> @@ -226,8 +226,9 @@
>  
>  <target name="unix-init" depends="mac-init" if="is-unix">
>  
> -    <property name="compiler" value="gcc"/>
> +    <!-- <property name="compiler" value="gcc"/> -->
>  
> +    <property name="apr-compiler" value="gcc"/>
>      <property name="lib.prefix" value="lib"/>
>      <property name="lib.extension" value=".a"/>
>      <property name="project.type" value="cbuilderx"/>
> @@ -542,6 +543,7 @@
>  </target>
>  
>  <target name="build-apr" depends="init" unless="apr-available">
> +    <property name="apr-compiler" value="${compiler}" />
>      <antcall target="untar-apr-src"/>
>  
>      <property name="apr.dir" location="${lib.dir}/apr-${apr.version}"/>
> @@ -552,7 +554,7 @@
>          <property name="version" value="${apr.version}"/>
>          <property name="debug" value="${debug}"/>
>          <property name="lib-suffix" value="${lib-suffix}"/>
> -        <property name="compiler" value="${compiler}"/>
> +        <property name="compiler" value="${apr-compiler}"/>
>          <property name="apr.dir" value="${apr.dir}"/>
>          <property name="apr.lib.dir" value="${apr.lib.dir}"/>
>          <property name="apr.lib.type" value="${apr.lib.type}"/>
> @@ -602,7 +604,7 @@
>          <property name="aprutil.dir" value="${aprutil.dir}"/>
>          <property name="debug" value="${debug}"/>
>          <property name="lib-suffix" value="${lib-suffix}"/>
> -        <property name="compiler" value="${compiler}"/>
> +        <property name="compiler" value="${apr-compiler}"/>
>          <property name="apr.include.dir" value="${apr.include.dir}"/>
>          <property name="apr.lib.dir" value="${apr.lib.dir}"/>
>          <property name="aprutil.lib.dir" value="${aprutil.lib.dir}"/>

If I'm missing an easier way to get this to compile on OSX I'd love to 
hear it

Derek


shai@rexee.com wrote:
> Hi
> I'm trying to build log4cxx on Mac version 10.4.7 but get the following
> error:
>
> ant -Dhas.wchar_t=0
>
> .....
> .....
> .....
>
>
> build:
>        [cc] Starting dependency analysis for 144 files.
>        [cc] 0 files are up to date.
>        [cc] 144 files to be recompiled from dependency analysis.
>        [cc] 144 total files to be compiled.
>        [cc] Starting link
>        [cc] ld: warning -prebind ignored because MACOSX_DEPLOYMENT_TARGET
> environment variable greater or equal to 10.4
>        [cc] ld: Undefined symbols:
>        [cc] __Unwind_Resume
>        [cc] __ZN7log4cxx7helpers13UnicodeHelper10decodeWideERPKwS3_
>        [cc] __ZN7log4cxx7helpers13UnicodeHelper10encodeWideEjPw
>        [cc] __ZN7log4cxx7helpers13UnicodeHelper10lengthUTF8Ew
>        [cc] /usr/bin/libtool: internal link edit command failed
>
> BUILD FAILED
> /Users/shaideljo/repos/src/users/shai-sand/logging-log4cxx/build.xml:723:
> gcc failed with return code 1
>   

________________________________________________________________________
The information transmitted is intended only for the person(s) or entity
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the
material from any computer. 

Paremus Limited.
107-111 Fleet Street, London EC4A 2AB.  Phone number +44 20 7936 9098
________________________________________________________________________

Mime
View raw message