1

i've installed mono on centos 6 via make && make install from source when i tried this sample: https://github.com/mono/mono/blob/master/samples/embed/teste.c

no error occured during the compilation, but when i run i got this:

[root@WOH_Test t01]# gcc -o teste teste.c `pkg-config --cflags --libs mono-2` -lm
[root@WOH_Test t01]# mcs test.cs
[root@WOH_Test t01]# ./teste test.exe
./teste: error while loading shared libraries: libmonoboehm-2.0.so.1: cannot open shared object file: No such file or directory

i can't figure where the problem is, any clue?

user2986683
  • 297
  • 1
  • 4
  • 12
  • Have you checked to see whether that package is installed and if it is located in the library path, see http://stackoverflow.com/questions/10963498/mono-shared-library-under-linux-location – Steve Mitcham Jan 15 '15 at 03:14
  • it's in /opt/mono/lib/ after make install, but not in /usr/lib64, but system locate this file only in lib64 – user2986683 Jan 15 '15 at 10:37

1 Answers1

0
  1. What do you have in /usr/local/lib? If you didn't use the --prefix option while running autogen.sh before the command make the libraries should be localed in /usr/local/lib. You should see in that directory something like this:

    me@mypc:/usr/local/lib$ ls -lah libmono-2.0.*
    lrwxrwxrwx. 1 me me 18 dic 19 00:38 libmono-2.0.a -> libmonoboehm-2.0.a
    lrwxrwxrwx. 1 me me 19 dic 19 00:38 libmono-2.0.la -> libmonoboehm-2.0.la
    lrwxrwxrwx. 1 me me 19 dic 19 00:38 libmono-2.0.so -> libmonoboehm-2.0.so
    lrwxrwxrwx. 1 me me 21 dic 19 00:38 libmono-2.0.so.1 -> libmonoboehm-2.0.so.1
    lrwxrwxrwx. 1 me me 25 dic 19 00:38 libmono-2.0.so.1.0.0 -> libmonoboehm-2.0.so.1.0.0
    
  2. If you can see the above libraries in /usr/local/lib your problem is related to where is ld searching for libraries. From this question: CentOS /usr/local/lib system wide $LD_LIBRARY_PATH I guess Centos6 does not have by default configuration for /usr/local/lib. If it is your case, just use the provided solutions in that question (any of them) and your program should work fine.

EDIT

From your comment if you want libmonoboehm-2.0.so.1 in the same path as the teste program and you do not want to touch anything else in your Centos6 you could do something like the following:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/teste/binary
./teste test.exe

But I wonder what output do you have when you run this command: pkg-config --cflags --libs mono-2 (it seems as if you already had a mono installation in your Centos6)

Anyhow, if you can modify your Centos6 the best is this answer: CentOS /usr/local/lib system wide $LD_LIBRARY_PATH. You do that once and you will be able to run any mono program without having to mess with the LD_LIBRARY_PATH environment variable. In your case you should do the following:

1. Edit /etc/ld.so.conf
2. Write this: /opt/mono/lib
3. Run ldconfig -v as root
4. Your Centos6 is ready to run your mono programs whenever you wish (even if you restart your Centos6 machine)

END EDIT

Community
  • 1
  • 1
Gooseman
  • 2,102
  • 17
  • 16
  • i compiled mono myself like this
    ./configure --prefix=/opt/mono make && make install it is located in /opt/mono/lib however when i put libmonoboehm in /usr/lib64, it works but i dont want to put it there, can i put it together with the teste binary?
    – user2986683 Jan 09 '15 at 04:56
  • You can, but you need the `LD_LIBRARY_PATH` environment variable because your library is located in a special path. See my `EDIT` just in case it helps you. – Gooseman Jan 09 '15 at 12:57