[Mono-list] Re: Troubles compiling mono on cygwin

Adam Jackson adamjackson1@attbi.com
Tue, 24 Dec 2002 14:37:47 -0800


I am having the same exact problem.  Has anyone figured out a solution
yet?

The generated Makefile for mono/mono/jit seems to contain definitions
for linking with glib but then they aren't actually used on the link
command line.  It's as if automake is finding the libraries properly,
but then it doesn't think that the JIT needs them to link - which is not
the case.

Here are the lines from the Makefile that seem relevant.  Libmono.la is
the target that fails to build.  I have reordered the definitions to
place them close to where they are used.

These defines seem relevant, but not actually used:

BASE_DEPENDENCIES_CFLAGS =  -I/home/aj/install/include/glib-2.0
-I/home/aj/install/lib/glib-2.0/include
BASE_DEPENDENCIES_LIBS =  -L/home/aj/install/lib -lglib-2.0 -lintl
-liconv
BUILD_GLIB_CFLAGS =  -I/home/aj/install/include/glib-2.0
-I/home/aj/install/lib/glib-2.0/include
BUILD_GLIB_LIBS =  -L/home/aj/install/lib -lglib-2.0 -lintl -liconv
GLIB_CFLAGS =  -I/home/aj/install/include/glib-2.0
-I/home/aj/install/lib/glib-2.0/include
GLIB_LIBS =  -L/home/aj/install/lib -lglib-2.0 -lintl -liconv
GMODULE_CFLAGS =  -I/home/aj/install/include/glib-2.0
-I/home/aj/install/lib/glib-2.0/include
GMODULE_LIBS =  -Wl,--export-dynamic  -L/home/aj/install/lib
-lgmodule-2.0 -lglib-2.0 -lintl -liconv
LIBC = libc.so.6
LIBOBJS =

These are the defines that are used, followed by the actual link line:

am__objects_1 = win32-exception.lo codegen-x86.lo emit-x86.lo regset.lo
\
        debug.lo debug-stabs.lo debug-dwarf2.lo jit.lo trampoline.lo \
        exception.lo linear-scan.lo helpers.lo
am_libmono_la_OBJECTS = $(am__objects_1)
libmono_la_OBJECTS = $(am_libmono_la_OBJECTS)
libmono_la_DEPENDENCIES = ../metadata/libmonoruntime.la \
        ../metadata/libmetadata.la ../io-layer/libwapi.la \
        ../utils/libmonoutils.la ../os/libmonoos.la
#libmono_la_DEPENDENCIES =
SHELL = /bin/bash
top_builddir = ../..
LIBTOOL = $(SHELL) $(top_builddir)/libtool
CC = gcc -mno-cygwin
CCLD = $(CC)
CFLAGS = -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations
-Wstrict-prototypes  \
         -Wmissing-prototypes -Wnested-externs -Wpointer-arith
-Wno-cast-qual -Wcast-align -Wwrite-strings
LDFLAGS =  -L/home/aj/install/lib
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
prefix = D:/OpenSource/cygwin/home/aj/install
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
srcdir = .
libmono_la_LDFLAGS = -Wl,-version-script=$(srcdir)/ldscript
libmono_la_LIBADD = \
        ../metadata/libmonoruntime.la   \
        ../metadata/libmetadata.la      \
        ../io-layer/libwapi.la          \
        ../utils/libmonoutils.la        \
        ../os/libmonoos.la
LIBS =  -lgc  -lws2_32 -lpsapi
libmono.la: $(libmono_la_OBJECTS) $(libmono_la_DEPENDENCIES)
        $(LINK) -rpath $(libdir) $(libmono_la_LDFLAGS)
$(libmono_la_OBJECTS) $(libmono_la_LIBADD) $(LIBS)


I fixed thousands of the missing symbols by changing LIBS to:

LIBS = $(GMODULE_LIBS) -lgc  -lws2_32 -lpsapi

But now I still have a few undefined symbols (e.g. __assert, __errno,
and _GC_malloc) and I do not know the correct incantations to fix them.

Does anyone know how I can either:
1.  Fix the build process so that it works properly, or
2.  Fix the Makefile so that I can at least get the JIT to link
manually.

Thanks,
Adam

p.s.  The current results of running "make" are:

make
make  all-am
make[1]: Entering directory `/home/aj/mono/mono/jit'
/bin/bash ../../libtool --mode=link gcc -mno-cygwin  -g -Wall -Wunused
-Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmi
ssing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual
-Wcast-align -Wwrite-strings  -L/home/aj/install/lib -o libmono.la
-rpath D
:/OpenSource/cygwin/home/aj/install/lib -Wl,-version-script=./ldscript
win32-exception.lo codegen-x86.lo emit-x86.lo regset.lo debug.lo debu
g-stabs.lo debug-dwarf2.lo jit.lo trampoline.lo exception.lo
linear-scan.lo helpers.lo ../metadata/libmonoruntime.la
../metadata/libmetadata
.la ../io-layer/libwapi.la ../utils/libmonoutils.la ../os/libmonoos.la
-Wl,--export-dynamic  -L/home/aj/install/lib -lgmodule-2.0 -lglib-2.0
 -lintl -liconv   -lgc  -lws2_32 -lpsapi
rm -fr  .libs/libmono.dll.a .libs/libmono.lax

*** Warning: linker path does not have real file for library -lgc.
*** I have the capability to make that library automatically link in
when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libgc and none of the candidates passed a file format test
*** using a file magic. Last file checked:
/home/aj/install/lib/libglib-2.0-0.dll
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
rm -fr .libs/libmono.lax
mkdir .libs/libmono.lax
rm -fr .libs/libmono.lax/libmonoruntime.a
mkdir .libs/libmono.lax/libmonoruntime.a
(cd .libs/libmono.lax/libmonoruntime.a && ar x
/home/aj/mono/mono/jit/../metadata/.libs/libmonoruntime.a)
rm -fr .libs/libmono.lax/libmetadata.a
mkdir .libs/libmono.lax/libmetadata.a
(cd .libs/libmono.lax/libmetadata.a && ar x
/home/aj/mono/mono/jit/../metadata/.libs/libmetadata.a)
rm -fr .libs/libmono.lax/libwapi.a
mkdir .libs/libmono.lax/libwapi.a
(cd .libs/libmono.lax/libwapi.a && ar x
/home/aj/mono/mono/jit/../io-layer/.libs/libwapi.a)
rm -fr .libs/libmono.lax/libmonoutils.a
mkdir .libs/libmono.lax/libmonoutils.a
(cd .libs/libmono.lax/libmonoutils.a && ar x
/home/aj/mono/mono/jit/../utils/.libs/libmonoutils.a)
rm -fr .libs/libmono.lax/libmonoos.a
mkdir .libs/libmono.lax/libmonoos.a
(cd .libs/libmono.lax/libmonoos.a && ar x
/home/aj/mono/mono/jit/../os/.libs/libmonoos.a)
gcc -shared  .libs/win32-exception.o .libs/codegen-x86.o
.libs/emit-x86.o .libs/regset.o .libs/debug.o .libs/debug-stabs.o
.libs/debug-dwarf
2.o .libs/jit.o .libs/trampoline.o .libs/exception.o .libs/linear-scan.o
.libs/helpers.o .libs/libmono.lax/libmonoruntime.a/appdomain.o .lib
s/libmono.lax/libmonoruntime.a/debug-mono-symfile.o
.libs/libmono.lax/libmonoruntime.a/decimal.o
.libs/libmono.lax/libmonoruntime.a/exceptio
n.o .libs/libmono.lax/libmonoruntime.a/file-io.o
.libs/libmono.lax/libmonoruntime.a/gc.o
.libs/libmono.lax/libmonoruntime.a/icall.o .libs/li
bmono.lax/libmonoruntime.a/marshal.o
.libs/libmono.lax/libmonoruntime.a/object.o
.libs/libmono.lax/libmonoruntime.a/process.o .libs/libmono.
lax/libmonoruntime.a/profiler.o
.libs/libmono.lax/libmonoruntime.a/rand.o
.libs/libmono.lax/libmonoruntime.a/reflection.o .libs/libmono.lax/
libmonoruntime.a/socket-io.o
.libs/libmono.lax/libmonoruntime.a/string-icalls.o
.libs/libmono.lax/libmonoruntime.a/sysmath.o .libs/libmono.l
ax/libmonoruntime.a/threadpool.o
.libs/libmono.lax/libmonoruntime.a/threads.o
.libs/libmono.lax/libmonoruntime.a/unicode.o  .libs/libmono.la
x/libmetadata.a/assembly.o .libs/libmono.lax/libmetadata.a/class.o
.libs/libmono.lax/libmetadata.a/debug-helpers.o
.libs/libmono.lax/libmeta
data.a/domain.o .libs/libmono.lax/libmetadata.a/image.o
.libs/libmono.lax/libmetadata.a/loader.o
.libs/libmono.lax/libmetadata.a/mempool.o .
libs/libmono.lax/libmetadata.a/metadata.o
.libs/libmono.lax/libmetadata.a/mono-config.o
.libs/libmono.lax/libmetadata.a/mono-endian.o .libs/
libmono.lax/libmetadata.a/opcodes.o
.libs/libmono.lax/libmetadata.a/rawbuffer.o
.libs/libmono.lax/libmetadata.a/verify.o  .libs/libmono.lax/
libwapi.a/io-layer-dummy.o  .libs/libmono.lax/libmonoutils.a/mono-hash.o
.libs/libmono.lax/libmonoutils.a/mono-md5.o .libs/libmono.lax/libmo
noutils.a/mono-sha1.o .libs/libmono.lax/libmonoutils.a/monobitset.o
.libs/libmono.lax/libmonoutils.a/strtod.o  .libs/libmono.lax/libmonoos.a
/util.o   -L/usr/lib -L/home/aj/install/lib -lgmodule-2.0 -lglib-2.0
/usr/lib/libintl.dll.a /usr/lib/libiconv.dll.a -lws2_32 -lpsapi  -Wl,-v
ersion-script=./ldscript -Wl,--export-dynamic -o .libs/cygmono-0.dll
-Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libmono.dll.a
Creating library file: .libs/libmono.dll.a
.libs/codegen-x86.o(.text+0x3245): In function `mono_burg_emit_16':
/home/aj/mono/mono/jit/codegen-x86.c:1259: undefined reference to
`__assert'
.libs/codegen-x86.o(.text+0x326d):/home/aj/mono/mono/jit/codegen-x86.c:1
259: undefined reference to `__assert'
.libs/codegen-x86.o(.text+0x3310):/home/aj/mono/mono/jit/codegen-x86.c:1
259: undefined reference to `__assert'
.libs/codegen-x86.o(.text+0x5495): In function `mono_burg_emit_26':
/home/aj/mono/mono/jit/codegen-x86.c:1484: undefined reference to
`__assert'
.libs/codegen-x86.o(.text+0x54bd):/home/aj/mono/mono/jit/codegen-x86.c:1
484: undefined reference to `__assert'
.libs/codegen-x86.o(.text+0x5560):/home/aj/mono/mono/jit/codegen-x86.c:1
484: more undefined references to `__assert' follow
.libs/debug.o(.text+0x10b6): In function `debug_load_method_lines':
/home/aj/mono/mono/jit/debug.c:360: undefined reference to `__errno'
.libs/debug.o(.text+0x1194):/home/aj/mono/mono/jit/debug.c:398:
undefined reference to `__errno'
.libs/debug-stabs.o(.text+0xa47): In function `mono_debug_write_stabs':
/home/aj/mono/mono/jit/debug-stabs.c:196: undefined reference to
`__errno'
.libs/debug-dwarf2.o(.text+0x3363): In function
`mono_debug_write_dwarf2':
/home/aj/mono/mono/jit/debug-dwarf2.c:1159: undefined reference to
`__errno'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x19a): In function
`object_register_finalizer':
/home/aj/mono/mono/metadata/gc.c:79: undefined reference to `_GC_base'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x214):/home/aj/mono/mono/
metadata/gc.c:80: undefined reference to `_GC_register_finalizer_no_
order'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x40c): In function
`mono_domain_finalize':
/home/aj/mono/mono/metadata/gc.c:166: undefined reference to
`_GC_gcollect'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x441): In function
`ves_icall_System_GC_InternalCollect':
/home/aj/mono/mono/metadata/gc.c:179: undefined reference to
`_GC_gcollect'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x45b): In function
`ves_icall_System_GC_GetTotalMemory':
/home/aj/mono/mono/metadata/gc.c:190: undefined reference to
`_GC_gcollect'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x460):/home/aj/mono/mono/
metadata/gc.c:191: undefined reference to `_GC_get_heap_size'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x65f): In function
`ves_icall_System_GCHandle_GetTargetHandle':
/home/aj/mono/mono/metadata/gc.c:293: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x671):/home/aj/mono/mono/
metadata/gc.c:294: undefined reference to `_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x715):/home/aj/mono/mono/
metadata/gc.c:312: undefined reference to `_GC_unregister_disappeari
ng_link'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x74f):/home/aj/mono/mono/
metadata/gc.c:314: undefined reference to `_GC_general_register_disa
ppearing_link'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x7f7):/home/aj/mono/mono/
metadata/gc.c:338: undefined reference to `_GC_general_register_disa
ppearing_link'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0x92d): In function
`ves_icall_System_GCHandle_FreeHandle':
/home/aj/mono/mono/metadata/gc.c:366: undefined reference to
`_GC_unregister_disappearing_link'
.libs/libmono.lax/libmonoruntime.a/gc.o(.text+0xb17): In function
`finalizer_thread':
/home/aj/mono/mono/metadata/gc.c:430: undefined reference to
`_GC_invoke_finalizers'
.libs/libmono.lax/libmonoruntime.a/icall.o(.text+0x616c): In function
`ves_icall_System_Environment_GetEnvironmentVariableNames':
/home/aj/mono/mono/metadata/icall.c:2870: undefined reference to
`___p__environ'
.libs/libmono.lax/libmonoruntime.a/icall.o(.text+0x61ba):/home/aj/mono/m
ono/metadata/icall.c:2877: undefined reference to `___p__environ'
.libs/libmono.lax/libmonoruntime.a/object.o(.text+0x50d): In function
`mono_class_vtable':
/home/aj/mono/mono/metadata/object.c:177: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/object.o(.text+0x1b2d): In function
`mono_object_allocate':
/home/aj/mono/mono/metadata/object.c:767: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/object.o(.text+0x1e8f): In function
`mono_array_new_full':
/home/aj/mono/mono/metadata/object.c:943: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/reflection.o(.text+0x63f3): In
function `mono_image_basic_init':
/home/aj/mono/mono/metadata/reflection.c:2472: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/reflection.o(.text+0x7496): In
function `mono_assembly_get_object':
/home/aj/mono/mono/metadata/reflection.c:2922: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/reflection.o(.text+0x7637):/home/aj/m
ono/mono/metadata/reflection.c:2946: more undefined references to `_
GC_malloc' follow
.libs/libmono.lax/libmonoruntime.a/sysmath.o(.text+0x275): In function
`ves_icall_System_Math_Log':
/home/aj/mono/mono/metadata/sysmath.c:132: undefined reference to
`__imp___HUGE'
.libs/libmono.lax/libmonoruntime.a/sysmath.o(.text+0x2ed): In function
`ves_icall_System_Math_Log10':
/home/aj/mono/mono/metadata/sysmath.c:145: undefined reference to
`__imp___HUGE'
.libs/libmono.lax/libmonoruntime.a/threads.o(.text+0x679): In function
`mon_new':
/home/aj/mono/mono/metadata/threads.c:476: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoruntime.a/threads.o(.text+0x6a7):/home/aj/mono/
mono/metadata/threads.c:477: undefined reference to `_GC_register_fi
nalizer'
.libs/libmono.lax/libmetadata.a/class.o(.text+0x2aa): In function
`mono_class_from_typeref':
/home/aj/mono/mono/metadata/class.c:88: undefined reference to
`__imp___iob'
.libs/libmono.lax/libmetadata.a/domain.o(.text+0x3c9): In function
`mono_domain_create':
/home/aj/mono/mono/metadata/domain.c:168: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmetadata.a/domain.o(.text+0x3f7):/home/aj/mono/mono
/metadata/domain.c:169: undefined reference to `_GC_register_finaliz
er'
.libs/libmono.lax/libmetadata.a/image.o(.text+0x16f2): In function
`mono_image_strerror':
/home/aj/mono/mono/metadata/image.c:715: undefined reference to
`__errno'
.libs/libmono.lax/libmonoutils.a/mono-hash.o(.text+0x39): In function
`mono_g_hash_table_new_full':
/home/aj/mono/mono/utils/mono-hash.c:152: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoutils.a/mono-hash.o(.text+0x9f):/home/aj/mono/m
ono/utils/mono-hash.c:163: undefined reference to `_GC_malloc'
.libs/libmono.lax/libmonoutils.a/mono-hash.o(.text+0xd78): In function
`g_hash_table_resize':
/home/aj/mono/mono/utils/mono-hash.c:606: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoutils.a/mono-hash.o(.text+0xe7c): In function
`g_hash_node_new':
/home/aj/mono/mono/utils/mono-hash.c:645: undefined reference to
`_GC_malloc'
.libs/libmono.lax/libmonoutils.a/strtod.o(.text+0x150a): In function
`bsd_strtod':
/home/aj/mono/mono/utils/strtod.c:1390: undefined reference to `__errno'
.libs/libmono.lax/libmonoutils.a/strtod.o(.text+0x1515):/home/aj/mono/mo
no/utils/strtod.c:1392: undefined reference to `__imp___HUGE'
.libs/libmono.lax/libmonoutils.a/strtod.o(.text+0x16c0):/home/aj/mono/mo
no/utils/strtod.c:1443: undefined reference to `__errno'
collect2: ld returned 1 exit status
make[1]: *** [libmono.la] Error 1
make[1]: Leaving directory `/home/aj/mono/mono/jit'
make: *** [all] Error 2


> On Sat, 2002-11-02 at 19:04, Norbert Harrer wrote:
> > Hi.
> > 
> > This is my first time compiling mono on cygwin. Unfortunately I am
> > playing around with it since two days now without success.
> 
> CVS mono built for me on cygwin on Thursday (when I fixed a problem in
> mono/interpreter/Makefile.am that I introduced when fixing the
makefiles
> for automake 1.6).
> 
> > 
> > I am using mono-build-w32.sh. It downloaded the mono source code and
> > some packages, ran autogen.sh and make. But make failed because of
> > some funny lines in mono/mono/Makefile [see makefile log 1 at end].
> > Here are the lines that caused the failure (line 310):
> > 
> > if PLATFORM_WIN32
> >         arch monograph interpreter jit tests benchmark
> > else
> >         arch monograph interpreter jit tests benchmark handles
> > endif
> 
> Very strange, this hasnt been changed in months.
> 
> > 
> > Somewhere else I read about using the devel version of automake if
> > something goes wrong. So I removed the two lines which set
AUTO_STABLE
> > and AUTO_DEVEL to /usr/autotool/stable in mono-build-w32.sh. And
> > hurray, the newly generated Makefiles compiled away quite a while.
> > 
> > Until they hit mono/mono/jit [see makefile log 2].
> 
> Yes, this breaks on cygwin unless you use the stable autotools.  It
> looks to me like the devel libtool is broken.
> 
> 
> > autoconf-devel:  2.53a-1
> > autoconf-stable: 2.13-4
> > automake-devel:  1.6.2-1
> > automake-stable: 1.4p5-5
> > gcc:             3.2-1
> > gcc-mingw:       3.2-20020817-1
> > make:            3.79.1-7
> > mingw-runtime:   2.2-1
> 
> I have identical autoconf and automake packages installed, but gcc
2.95
> and mingw-runtime 2.1-1.  Neither of those should effect automake that
> way.
> 
> - Dick