[Mono-dev] R <-> mono: linking to libmono.a on windows (cygwin) problems

Robert Jordan robertj at gmx.net
Sat Dec 17 09:26:32 EST 2011


Hi Jonathan,

Instead of passing

c:/cygwin/home/jonathan.shore/Dev/hf/src/Libraries/CApi/lib/win32/libmono-2.0.dll.a

directly to the linker, try this:

-Lc:/cygwin/home/jonathan.shore/Dev/hf/src/Libraries/CApi/lib/win32
-lmono-2.0

MinGW is smart enough to fetch the correct library (it will default
to the import lib).

BTW, you're also missing some compiler & linker options (see
$prefix/lib/pkgconfig/mono-2.pc) At least "-mms-bitfields"
seems to be important, although I don't know if Mono is
exposing bit fields through its public API.

Robert


On 17.12.2011 01:30, Jonathan Shore wrote:
> Should I install a separate ming-gcc and try building in the cmd shell or
> is there something else likely to be wrong?   the -mno-cygwin option is
> recognized, but I get the same issue.   Here is the -v option which shows
> the final linking:
>
>       [exec]  /usr/lib/gcc/i686-pc-mingw32/3.4.4/collect2.exe -Bdynamic -o
> rDotNet.dll
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/crt2.o
> -Lc:/cygwin/home/jonathan.shore/Dev/hf/src/Libraries/CApi/lib/win32
> -Lc:/cygwin/home/jonathan.shore/Dev/hf/src/Libraries/CApi/bin/Debug
> -Lc:/Program Files/R/R-2.14.0/bin/i386/
> -L/usr/lib/gcc/i686-pc-mingw32/3.4.4 -L/usr/lib/gcc/i686-pc-mingw32/3.4.4
> -L/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib
> -L/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../.. -L
> /usr/i686-pc-mingw32/sys-root/mingw/lib
> c:/cygwin/home/jonathan.shore/Dev/hf/src/Libraries/CApi/lib/win32/libmono-2.0.dll.a
> -lR -lmono-2.0 /tmp/ccILXCG3.o /tmp/ccJEF9fo.o /tmp/ccanTwx7.o
> /tmp/ccplAvT1.o /tmp/ccz8AVe8.o /tmp/ccfiDw2B.o /tmp/ccTcsUKn.o
> /tmp/cc9UqTZx.o /tmp/ccqfDboR.o /tmp/ccn1IMSt.o /tmp/ccWYgkXj.o -lstdc++
> -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -lmingw32 -luser32 -lkernel32
> -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x91): undefined reference to
> `_mono_string_new'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x10e): undefined reference to
> `_mono_get_double_class'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x130): undefined reference to
> `_mono_value_box'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x1ca): undefined reference to
> `_mono_get_int32_class'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x1ec): undefined reference to
> `_mono_value_box'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x20c): undefined reference to
> `_mono_get_int32_class'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x22e): undefined reference to
> `_mono_array_new'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x25a): undefined reference to
> `_mono_array_addr_with_size'
>       [exec] /tmp/ccfiDw2B.o:ToCLR.cpp:(.text+0x2a0): undefined reference to
> `_mono_get_string_class'
>       ...
>
>
> On Fri, Dec 16, 2011 at 3:30 PM, Robert Jordan<robertj at gmx.net>  wrote:
>
>> Hi,
>>
>> Linking with libmono.a is not supported under Cygwin.
>> Moreover, linking a cygwin app with libmono.la (libmono.dll.a
>> ->  mono.dll) would disable Mono's SIGSEGV handler. This means
>> that NullReferenceExceptions would crash your app.
>>
>>> A compilation like:
>>>
>>> g++ -o rDotNet.dll -I<mono include dir>   -L<R libs>   -L<mono libs>
>> *.cpp -lR
>>> -lmono-2.0
>>
>> Try g++ -mno-cywin ...
>>
>> It should work if the R libs were compiled with -mno-cywin as well.
>>
>> Robert
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
>
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list