Unable to generate dll files

  • Paul Kearney

    Paul Kearney - 2006-09-01


    I am having a problem getting the cc task to generate dll files when compiling. Instead it generates .so files even though I am specifying .dll in the outfile and runnig under windows.

    In my build file I am generating a header file from a Java class using the javah tool and then attempting to have the C file that I have written to be compiled by gcc.

    I can get the code to compile under cygwin using:
    gcc -mno-cygwin -I/cygdrive/c/jdk1.6.0/include -I/cygdrive/c/jdk1.6.0/include/win32  -Wl,--add-stdcall-alias -shared -o $result.dll code.c -L./ -lexternal

    I would prefer however to use ANT to build and compile the C code however.

    Here is a shortened version of my build file:

      <property environment="env" /> 
      <property name="src.c" value="${src}/c" />
      <property name="dll.files" value="${staging}/dll" />
      <property name="c.headers" value="${staging}/h" />
      <path id="gcc.path" description="Classpath for compiling C classes">   
        <pathelement location="${c.headers}" />
        <pathelement location="${env.JAVA_HOME}/include" />
        <pathelement location="${env.JAVA_HOME}/include/win32" />
      <target name="gcc" depends="javah" description="Compile C files">
          <cc outtype="shared" name="gcc" objdir="${dll.files}" outfile="${dll.files}/result.dll">
            <compilerarg value="-D_REENTRANT" />
            <compilerarg value="-D_GNU_SOURCE" />
            <compilerarg value="-D__int64=long long" />
            <fileset dir="${src.c}" />
            <includepath refid="gcc.path" />
            <libset libs="epanet2" />
            <linkerarg value="-Wl" />
            <linkerarg value="--add-stdcall-alias" />

    Hope you can help and thanks in advance.


    • Paul Kearney

      Paul Kearney - 2006-09-01

      Sorry cygwin command should be:
      gcc -mno-cygwin -I/cygdrive/c/jdk1.6.0/include -I/cygdrive/c/jdk1.6.0/include/win32 -Wl,--add-stdcall-alias -shared -o result.dll code.c -L./ -lexternal

      a spare $ got in there somehow.

      Can I also add that the output filename generated is of the form:


      I did attempt just renaming the file to result.dll as a quick hack but this did not work.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks