Dear,
I try to compile dia2code for Windows but I found some problem.
First, I run autoreconf -i --force :
aclocal-1.14: warning: autoconf input should be named 'configure.ac', not 'configure.in'
autoheader-2.69: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
autoheader-2.69: WARNING: and `config.h.top', to define templates for `config.h.in'
autoheader-2.69: WARNING: is deprecated and discouraged.
autoheader-2.69:
autoheader-2.69: WARNING: Using the third argument of `AC_DEFINE' and
autoheader-2.69: WARNING: `AC_DEFINE_UNQUOTED' allows one to define a template without
autoheader-2.69: WARNING: `acconfig.h':
autoheader-2.69:
autoheader-2.69: WARNING: AC_DEFINE([NEED_FUNC_MAIN], 1,
autoheader-2.69: [Define if a function `main' is needed.])
autoheader-2.69:
autoheader-2.69: WARNING: More sophisticated templates can also be produced, see the
autoheader-2.69: WARNING: documentation.
automake-1.14: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.in:6: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
dia2code/Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
automake-1.14: warning: autoconf input should be named 'configure.ac', not 'configure.in'
So first, I renamed configure.in to configure.ac. For the rest, I do not really care.
We compiling, I have :
dia2code.c: In function ‘create_package_dir’:
dia2code.c:239:52: erreur: ‘S_IRGRP’ undeclared (first use in this function)
mode_t dir_mask = S_IRUSR | S_IWUSR | S_IXUSR |S_IRGRP | S_IXGRP;
^
dia2code.c:239:52: note: each undeclared identifier is reported only once for each function it appears in
dia2code.c:239:62: erreur: ‘S_IXGRP’ undeclared (first use in this function)
mode_t dir_mask = S_IRUSR | S_IWUSR | S_IXUSR |S_IRGRP | S_IXGRP;
Some research shows that theses 2 flags have no meaning in Windows.
So I propose :
mode_t dir_mask = S_IRUSR | S_IWUSR | S_IXUSR;
#if !defined(_WIN64) && !defined(_WIN32)
dir_mask = dir_mask | S_IRGRP | S_IXGRP;
#endif
Then I have
i686-pc-mingw32-gcc -g -O2 -o dia2code.exe dia2code.o main.o parse_diagram.o scan_tree.o generate_code_c.o generate_code_java.o generate_code_cpp.o generate_code_ada.o generate_code_sql.o generate_code_python.o generate_code_php.o generate_code_shp.o generate_code_idl.o generate_code_csharp.o generate_code_php_five.o generate_code_ruby.o generate_code_as3.o decls.o includes.o source_parser.o comment_helper.o -lxml2 -lz -lm
dia2code.o: dans la fonction « find_diaoid »:
/tmp/dia2code-git/dia2code/dia2code.c:1001: référence indéfinie vers « strndup »
source_parser.o: dans la fonction « sourceblock_new »:
/tmp/dia2code-git/dia2code/source_parser.c:80: référence indéfinie vers « strndup »
source_parser.o: dans la fonction « source_parse »:
/tmp/dia2code-git/dia2code/source_parser.c:153: référence indéfinie vers « strndup »
source_parser.o: dans la fonction « source_preserve »:
/tmp/dia2code-git/dia2code/source_parser.c:56: référence indéfinie vers « strndup »
But after some research, the code looks fine : there is
#define _GNU_SOURCE in dia2code.h
and adding
#define _POSIX_C_SOURCE 200809L
solve nothing. Looks like strndup is not in MinGW.
Adding (in dia2code.c) something like this help gcc.
#ifndef strndup
static size_t strnlen(const char *s, size_t max) {
register const char *p;
for(p = s; *p && max--; ++p);
return(p - s);
}
char* strndup(const char*s, size_t n)
{
char* newbuf = (char*)malloc(strnlen(s, n) + 1);
strncpy(newbuf, s, n-1);
return newbuf;
}
#endif
Then I have
i686-pc-mingw32-gcc -g -O2 -o dia2code.exe dia2code.o main.o parse_diagram.o scan_tree.o generate_code_c.o generate_code_java.o generate_code_cpp.o generate_code_ada.o generate_code_sql.o generate_code_python.o generate_code_php.o generate_code_shp.o generate_code_idl.o generate_code_csharp.o generate_code_php_five.o generate_code_ruby.o generate_code_as3.o decls.o includes.o source_parser.o comment_helper.o -lxml2 -lz -lm -ldl
/usr/libexec/gcc/i686-pc-mingw32/ld: ne peut trouver -ldl
is ldl is necessary ?
PS removing it from configure.in do not solve the problem. I don't know why.
What do you think of all this things ?
About strnlen, I discover : http://cgit.freedesktop.org/cairo/tree/util/cairo-missing/strndup.c