Mono shared library under linux location
I think you have to use the environment variable LD_LIBRARY_PATH when launching your program:
LD_LIBRARY_PATH=. mono yourapp.exe
How do I tell mono where to find a library?
After posting on the mono list and hunting a bit further, the answer appears to be "don't use Gnu.Getopt"; use Ndesk.Options instead as per GetOpt library for C#.
Where to put Files for Mono Application in Unix
You should look at an already established Mono app for reference. For example let's take MonoDevelop:
The exe file goes to /usr/lib/{appnameinlowercase}/bin/ , but they place a launcher script in /usr/bin, named {appnameinlowercase}, for easy launch from the command line (this script just calls
exec mono YourAppName.exe
).In .NET the config files need to be in the same directory as the executable file, so you could place them in /usr/lib/{appnameinlowercase}/bin, then later for convenience, put symlinks to them from /etc/{appnameinlowercase}/.
Correct, /var/log/{appnameinlowercase}/ should be fine.
Cannot access a Linux gcc compiled .so shared library from Windows Mono C# Project
You can't use a .so elf binary on Windows for your native code. You need to recompile it into a native binary supported by Windows (namely a .dll).
I suggest you read our wiki page about cross platform interop between managed an unmanaged code.
Linux, Mono, shared libs and unresolved symbols
You should specify the dependency when you link the wrapper library like
g++ -shared -Wl,-soname,libexif-wrapper.so.1 -o libexif-wrapper.so.1.0.1 libexif-wrapper.o -lc -lexif
When you do that the dynamic linker knows that libexif-wrapper depends on libexif and it can resolve the symbols on load.
embedding mono sample: error while loading shared libraries: libmonoboehm-2.0.so.1
What do you have in
/usr/local/lib
? If you didn't use the--prefix
option while runningautogen.sh
before the commandmake
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.0If you can see the above libraries in
/usr/local/lib
your problem is related to where isld
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
Related Topics
How to Programmatically Generate Keypress Events in C#
"The Controls Collection Cannot Be Modified Because the Control Contains Code Blocks"
Entering Keys Manually with Entity Framework
Binding a Button's Visibility to a Bool Value in Viewmodel
Get Name of Property as a String
How Would You Do a "Not In" Query with Linq
Object Cannot Be Cast from Dbnull to Other Types
Generics Open and Closed Constructed Types
How to Check If a Type Is a Subtype or the Type of an Object
How to Use Visual Studio Code to Develop Unity3D Projects in Ubuntu
How to Shut Down the Computer from C#
How to Access Session Variables from Any Class in ASP.NET
Why Is It Bad to Use an Iteration Variable in a Lambda Expression
Inner Join of Datatables in C#
Convert Integer to Binary in C#
Differencebetween Task.Run() and Task.Factory.Startnew()
Why Does .Net Add an Additional Slash to the Already Existent Slashes in a Path