Bug 43473 - mkbundle fails with "ld: cannot find -lmono-2.0"
Summary: mkbundle fails with "ld: cannot find -lmono-2.0"
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Tools ()
Version: 4.4.2 (C7SR1)
Hardware: PC Linux
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-08-17 16:28 UTC by Rick Tillery
Modified: 2017-01-25 12:13 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Rick Tillery 2016-08-17 16:28:55 UTC
Failure occurred with mono-core 4.2.3 as well as 4.4.2.
System is CentOS 7.
(Test code borrowed from Mirco Bauer, Bug ID: 41731)

$ mono --version
Mono JIT compiler version 4.4.2 (Stable 4.4.2.11/f72fe45 Fri Jul 29 09:49:37 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            sgen

$ cat test.cs
public class MainClass {
        static void Main() {
        System.Console.WriteLine("Hello world");
        }
}

$ dmcs test.cs
$ mono test.exe
Hello world

$ mkbundle --static test.exe
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
OS is: Linux
Sources: 1 Auto-dependencies: False
   embedding: /home/.../test.exe
AS = as (default)
[execute cmd]: as -o temp.o temp.s 
Compiling:
CC = cc (default)
[execute cmd]: cc -o 'a.out' -Wall `pkg-config --cflags mono-2` temp.c  `pkg-config --libs-only-L mono-2` -Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic `pkg-config --libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //"` temp.o
/usr/bin/ld: cannot find -lmono-2.0
collect2: error: ld returned 1 exit status
ERROR: [Fail] 256

$ ll /usr/lib64/libmono*
lrwxrwxrwx. 1 root root       17 Aug 17 09:16 libmono-2.0.a -> libmonosgen-2.0.a
lrwxrwxrwx. 1 root root       18 Aug 17 09:16 libmono-2.0.so -> libmonosgen-2.0.so                                                                              
lrwxrwxrwx. 1 root root       20 Aug 17 09:16 libmono-2.0.so.1 -> libmonosgen-2.0.so.1                                                                          
lrwxrwxrwx. 1 root root       24 Aug 17 09:16 libmono-2.0.so.1.0.0 -> libmonosgen-2.0.so.1.0.0                                                                  
lrwxrwxrwx. 1 root root       25 Aug 17 09:16 libmonoboehm-2.0.so -> libmonoboehm-2.0.so.1.0.0                                                                  
lrwxrwxrwx. 1 root root       25 Aug 17 09:16 libmonoboehm-2.0.so.1 -> libmonoboehm-2.0.so.1.0.0                                                                
-rwxr-xr-x. 1 root root 16646152 Jul 29 04:55 libmonoboehm-2.0.so.1.0.0
-rw-r--r--. 1 root root   244438 Jul 29 04:56 libmono-profiler-aot.a
lrwxrwxrwx. 1 root root       29 Aug 17 09:16 libmono-profiler-aot.so -> libmono-profiler-aot.so.0.0.0
lrwxrwxrwx. 1 root root       29 Aug 17 09:16 libmono-profiler-aot.so.0 -> libmono-profiler-aot.so.0.0.0
-rwxr-xr-x. 1 root root   503313 Jul 29 04:55 libmono-profiler-aot.so.0.0.0
-rw-r--r--. 1 root root   252192 Jul 29 04:56 libmono-profiler-iomap.a
lrwxrwxrwx. 1 root root       31 Aug 17 09:16 libmono-profiler-iomap.so -> libmono-profiler-iomap.so.0.0.0
lrwxrwxrwx. 1 root root       31 Aug 17 09:16 libmono-profiler-iomap.so.0 -> libmono-profiler-iomap.so.0.0.0
-rwxr-xr-x. 1 root root   551349 Jul 29 04:55 libmono-profiler-iomap.so.0.0.0
-rw-r--r--. 1 root root   330048 Jul 29 04:56 libmono-profiler-log.a
lrwxrwxrwx. 1 root root       29 Aug 17 09:16 libmono-profiler-log.so -> libmono-profiler-log.so.0.0.0
lrwxrwxrwx. 1 root root       29 Aug 17 09:16 libmono-profiler-log.so.0 -> libmono-profiler-log.so.0.0.0
-rwxr-xr-x. 1 root root   756204 Jul 29 04:55 libmono-profiler-log.so.0.0.0
-rw-r--r--. 1 root root    91228 Jul 29 04:56 libmono-profiler-log-static.a
lrwxrwxrwx. 1 root root       24 Aug 17 09:16 libmonosgen-2.0.so -> libmonosgen-2.0.so.1.0.0
lrwxrwxrwx. 1 root root       24 Aug 17 09:16 libmonosgen-2.0.so.1 -> libmonosgen-2.0.so.1.0.0
-rwxr-xr-x. 1 root root 18175778 Jul 29 04:55 libmonosgen-2.0.so.1.0.0

$ ld --version
GNU ld version 2.23.52.0.1-55.el7 20130226
Copyright 2013 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Comment 1 Alex Rønne Petersen 2016-08-29 06:45:23 UTC
I am not able to reproduce this on Mono master (amd64, Linux Mint). It could be the distro difference, but OTOH, there have been a lot of mkbundle fixes in master lately. Could you please try a nightly build?

See: http://www.mono-project.com/docs/getting-started/install/linux/ci-packages/
Comment 2 Pieter Germishuys 2017-01-24 10:48:42 UTC
Still seeing this on 4.6.2

$ mono --version
Mono JIT compiler version 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan  3 11:51:14 UTC 2017)

Is there a resolution to this other than trying to use the CI packages?
Comment 3 Jo Shields 2017-01-25 12:13:48 UTC
Fixed in alpha (build might take an hour or so to land).

diff --git a/mono-core.spec b/mono-core.spec
index 9f8dedf..ade5d47 100644
--- a/mono-core.spec
+++ b/mono-core.spec
@@ -183,8 +183,6 @@ rm -f %{buildroot}%{_libdir}/libMonoSupportW.*
 rm -f %{buildroot}%{_libdir}/libMonoPosixHelper.a
 rm -f %{buildroot}%{_libdir}/libikvm-native.a
 rm -f %{buildroot}%{_libdir}/libmono-llvm.a
-rm -f %{buildroot}%{_libdir}/libmonoboehm-2.0.a
-rm -f %{buildroot}%{_libdir}/libmonosgen-2.0.a
 
 # remove libgc cruft
 rm -rf %{buildroot}%{_datadir}/libgc-mono
@@ -1247,6 +1245,8 @@ Mono development tools.
 %{_prefix}/lib/mono/xbuild-frameworks
 %{_prefix}/lib64/mono/lldb
 %{_libdir}/libmono-2.0.a
+%{_libdir}/libmonosgen-2.0.a
+%{_libdir}/libmonoboehm-2.0.a
 
 
 %package -n mono-reactive