I am completely new to Mono and Gtk#. I'm developing an app on Linux but I want to run it on Windows as well. However, if I build the app using MonoDevelop and then run the .exe file in Windows, it doesn't launch.
Is it really possible to make Windows apps using Linux/Mono, or am I missing something?
Baltasarq is correct. The reason that your app won't run is that the dependent GTK# binaries are not on your target machine. The compiled .exe will run on any .NET implementation so long as it is of at least the .NET version that your executable targets and the dependent assemblies are available.
Like Symon said, you have to build your project on the operating system you're intending it to be be compiled for because of the resources (API's etc.) that specific operating system is loaded with.
When I have a problem like this, I simply use a virtual machine software like VirtualBox or VMware to run Windows and then install and run MonoDevelop inside of Windows. Don't worry about the expensive cost of Windows, for you can just get Windows from Microsoft's website here. There will be a little watermark in the corner of the screen because you didn't pay for the copy, but everything is still totally legal and fit for software development.
UPDATE:
A better method to do this is to install the GTK# dependencies and then recompile the program.
Related
I have developed a game on Windows 7 (64bit) in Visual Studio 2015 with the language C# and the MonoGame framework. The game works fine on Windows, but I also wanted to make the game to be playable on Linux. Therefore I installed VirtualBox with Ubuntu 15.10 (64bit) on my Windows PC, to test if I can make my game running on Ubuntu.
After trying to compile the game in different ways with no solution in sight, I came to the conclusion to ask a few questions here about deploying MonoGame to Linux:
Is it possible to compile a MonoGame game in VisualStudio 2015 on Windows for Linux in a...
1.1. MonoGame Linux Project?
1.2. MonoGame Windows OpenGL Project?
1.3. MonoGame Windows Project? (which my game currently is)
If [1.] what are the requirements and what programs need to be installed on Linux to run this [1.x] build?
Is it possible (and recommended) to compile the game in MonoDevelop on a virtual Ubuntu machine?
Is it even possible to run a MonoGame game on a virtual Ubuntu machine?
What is the proper executable file extension for a game on Linux? (Because Linux Project on Windows is only building a .exe)
I have almost no experience with Linux, so I hope someone can answer me these questions, maybe someone who has experience with porting a MonoGame game to linux.
Thanks.
Though the question is a few years old, it's deserving of an answer. I managed to make cross-platform builds for a game built in MonoGame through Mono's mkbundle. Here is a great tutorial for doing so on Windows.
You'll want to download the latest Mono version and append an "exe" extension to the file located at C:\Program Files (x86)\mono\bin\mono. Next download the appropriate runtime for the platform you want to deploy to, give it a "zip" extension, and extract it into the following path: C:\Users\youruserhere\Documents.mono\targets
After that, you should be ready to build; open up a Command Prompt and enter mkbundle --local-targets. If everything went smoothly, the runtimes you have installed should be displayed. After that is a matter of building an exe to the target platform.
Here's an example for building an application to Ubuntu: mkbundle HelloWorldConsole.exe --simple -o HelloWorldBundleUbuntu --cross mono-5.10.0-ubuntu-16.04-x64
Keep in mind that some classes not implemented in Mono, such as WebBrowser, will cause the build to fail. If this is the case, you may need to find a workaround.
With this you can run the file in Linux by entering ./HelloWorldBundleUbuntu in a Terminal. I've had no issues running the game this way in a virtual machine.
Lastly, if you want to go the .NET Core route, MonoGame has a WIP core fork that you can use, though I'm unsure how well it works.
To add to an already year old answer by Kimimaru, there's also the possibility to use MonoKickstart to get your Monogame executables up and running on Mac and Linux without the need to bundle anything. This is especially handy if your projects are a little difficult to bundle, because of third-party libraries or otherwise.
You simply unpack the Kickstart archive and paste your Windows executable ontop. By editing the .kick files to point to the appropriate executable, they will act as an intermediary to run your programs using mono (which is provided, as well, no need to install on target machine).
https://github.com/mrhelmut/MonoKickstart
I have years of experience developing on microsoft development stack primarily visual studio 2012/c#. But right now, im required to develop app on linux. While i know c++, its been years since i really touch that. I have few questions.
Can i develop using mono and compile binary for linux and windows with no code(or minimal) code changes?
Can i develop on windows platform using visual studio 2012, compile for linux on window platform? do i need to use virtual machine for compiling for linux in windows platform?
How do you setup your development environment if you want to develop linux app on windows platform(develop on windows, compile for linux and windows. my linux box use for testing is a separate machine.)
Some info on what im working on.
My project is about network channel analysis. The client is cheap industrial linux box most probably with no ui. Im using mono/c# to develop the client. The server would be windows develop using vs2012 c#. Most probably using wpf as ui. Im planning to share network/communication library between linux(client) and windows(server). My primary concern for using linux is for cost saving since the client is almost thousand units.
thank you.
Mono runs executables in PE (Portable Executable) format, the native file format of Windows. There's no need to "compile for Linux", as long as your app is pure MSIL. And even if you use native DLLs through p/invoke, Mono and Wine work together to run the Windows files on Linux.
(The a.out and ELF executable formats used by native Linux applications don't have mechanisms for storing .NET metadata, the PE format was modified to support .NET, so that's what .NET Framework (not Micro Framework) implementations use regardless of platform)
The most important things to consider at the beginning are,
WinForms of Mono is problematic. Not only most third party controls won't work properly, but also libgdiplus itself is not 100% compatible with Microsoft's GDI+. It might appear to be a sweet option, but later you might still need to fight hard against the incompatibilities.
WPF is not an option as Mono does not support it yet.
GTK# is your best choice for UI, which blends naturally with Linux distros. If you refactor your Windows project properly, you should be able to share the non-UI code between your Windows and Linux solutions. This is what Mono guys recommend (not only use native UI frameworks for Windows, Linux, but also for Mac/MonoMac, iOS/Xamarin.iOS, and Android/Xamarin.Android).
So go back to your questions,
You should never wish for no code change for a real world project. No, that's impossible. As I said earlier, you have a chance to share most non-UI portion.
You can develop the non-UI portion and the Windows only portion using VS2012 and test them out on Windows. If you plan to use Mono's WinForms or GTK#, you must develop and debug on Linux using MonoDevelop. Thus, you need either a virtual machine or physical machine of Linux.
For me, I frequently switch between Linux/MonoDevelop and Windows/VS.
As Mono + C# is much more productive than using C/C++, many successful Linux apps are developed on Mono, such as Banshee and Tomboy.
You can use Visual Studio without problems but for example you cannot use WPF, while Windows Forms are ok. For more information what you can use visit: http://www.mono-project.com/Compatibility
Moreover there exists Mono tools which integrates with VS: http://www.mono-project.com/GettingStartedWithMonoTools
I am creating a project on C#-.Net. The 'exe' file generated from the project is not executable on machines which do not have the .Net already installed. This error is popping up:
To run this application you first must install one of the following versions of the .NET.Framework: V4.0.30319
I don't want to make an installer file which installs the dependency files (.Net FW and other...) on PC.
As project requirement, I want to make an 'exe' that runs on every Windows PC without installing software or dependency sofware -> .Net FW. Just when clicked and the s/w exe should execute.
Is it possible to make such machine independent 'exe' for Windows from .Net ??
That's not exactly possible (there are some tools out there that will allow you to bundle dependencies, but I wouldn't recommend using them).
Your best possible approach to this is using an as-old-as-possible framework, for example .NET Framework 3.0. This way you'll use a framework version that is already preinstalled on pretty much all systems in use. Or in other words, you'll ensure your program runs on as many systems as possible out of the box. Just provide a link to the runtime in case someone is still missing it.
Also just to note that this is far better compared to what happened to the first few iterations of the .NET Framework: Those executables would just crash with a complex error message not telling the user that it's just the runtime missing. It improved a lot over time.
Also, just as an alternative: Have you thought about using ClickOnce deployment? This will allow you to provide users a simple and minimal installer they won't really see either. It will only download and install dependencies that are still missing. Also this is built into any edition of VisualStudio, even the Express ones.
This error is popping up
It is not an error. Just a friendly reminder to the user that your program need .NET 4 to be available before your program can run. He'll click "Yes, please!" and everything solves itself automagically.
You could create an installer to avoid the message. But, given that you don't want to do that, and it already takes care of it for you, there is very little point.
More about what this all looks like and why it works this way in this answer
"As project requirement, I want to make an 'exe' that runs on every Windows PC without installing software or dependency sofware -> .Net FW. Just when clicked and the s/w exe should execute.".
1) What if the version of Windows doesn't have any .Net Framework?
2) What if the version of Windows doesn't support any version of .Net Framework? (.Net didn't come around until Win2K/ME ish times, and Windows 95 won't take most .Net frameworks, 3.1 / 3.5 wont even take Mono)
"Is it possible to make such machine independent 'exe' for Windows from .Net ??"
Sounds like you're trying to make something like a Setup.exe that can be a single download that will work out the specifics after the fact... Actually the "machine independent" makes even C++ unsuitable, because while C++ will work on Windows, Mac, Linux, Unix, and a whole slew of more exotic systems with x86, x64, i64, PPC, ARM24/32/64 etc. (all of which exist with Windows installed on them, out there, in the wild, but are pretty rare) once the executable is compiled and linked, it will be targeted towards a single CPU architecture and OS. (OS/2, GEM and DOS all use .exe files, and there are some similarities between them, but most other OS don't require any specific file extension for executable binaries)
So, .Net isn't a terrible idea for this reason, any more than a .jar, .pl or .py would be. (which is relatively common for *nix software that you hope will run on Linux, Mac and BSD Unix... maybe even Solaris or HP/UX etc.) If you target MSIL, rather then x86 or x64, then your .exe will run on PPC Windows, DEC Alpha Windows, Itanium Windows, and ARM Windows, as well as the other two. (although this isn't what you are asking about) If you build it without a dependence on the WPF, or other Windows specific GUI engine, it will also work on Mac, Linux and BSD, so long as they have Mono installed. (it just may be worth considering, while you're at it... Versions of Windows Microsoft don't support with the appropriate .Net version will also need Mono to work this way)
To that end, I would recommend building a command-line executable in Mono, rather than .Net development environment. (Mono executable will run on .Net easier than .Net executables run on Mono... Though either is possible if you are careful about the dependencies you include in headers you import into your source)
I've had some success with this, writing a background service that would install on either Windows or Linux with the same binary executable. I used MonoDevelop. (https://www.monodevelop.com/) However, it's really just a flashy IDE around the core Mono development tools. (https://www.mono-project.com/)
I was making an OpenGL application with C# and Windows Forms.
Recently I thought about making it cross-platform, I mean to make it run on Windows, Linux and OS X. I have never even tried to make a cross platform application.
I did some research and found that I should use mono. Do applications made with MonoDevelop will run fine all of these platforms without any additional installations? If not, what exactly user will need to install to run that application?
Is there any easy way to write the code once and then build it for windows, linux and os x without requiring the additional installations?
Does applications made with MonoDevelop will run fine on windows, linux, os x without any additional installations?
Well. They will require Mono to be installed on Linux and OsX and the corresponding version of the .NET framework on Windows (or Mono there too).
When developing, you will of course need to keep cross platform concerns in mind (directory separators, for instance, though the Path class helps here), and Mono have created the migration analyzer to help with this - see MoMa.
Now, assuming you kept these in mind and that Mono and or the .NET framework is installed on the end user system, you shouldn't need anything additional to install.
Would it be possible to code and compile C#, on a Windows 8 Tablet (WinRT) (the ARM processor edition)?
Basically it comes down to this:
Is there a C# compiler that runs on ARM?
Is there and IDE that can run in WinRT?
If the above is true, I don't see any issue, but I currently can't find if the C# compiler runs on ARM (only a lot of posts about compiling for ARM). I've also looked at SharpDevelop, and found that their source code compiles for "Any CPU", which according to this post: Windows RT and c#, means that it'll run on ARM.
Sharpdevelop however requires .NET 4.0 "Full" runtime, which I couldn't find if WinRT has or not. I'm betting it doesn't, as WinRT is supposed to be a really lightweight edition of Windows.
As a sidenote, I know that Windows tablets will come in two editions, one for ARM and one for classic processors. The classic processors will run a normal Windows 8 edition, which means it can run all the native applications. Compiling C# wouldn't be an issue here - so the question is rather, can I do the same on ARM?
This would be awesome for travelling and trying out new ideas quickly.
Currently: no, and no.
It would certainly be possible to build a Windows Store app that contains an IDE and a C# compiler. However, you would not be able to run any programs built using such an app. Windows Store apps run with reduced privileges in a sandbox. In this sandbox, the CLR will only load system assemblies and assemblies contained in the app package. The app package is immutable and cannot be modified at runtime.
Actually, the .Net framework on the surface includes csc.exe, the Csharp compiler.
I've gotten code to compile, but WinRt doesn't seem to like it being run without proper signing.
The IDE won't happen for a while, not yet at least. I'm sure that with proper signing, it is possible to run a compiled executable.
Or the other guy might be right and it isn't just an issue of signing.
I've ported SharpDevelop to run on unlocked Windows RT devices, it works at least for C# Windows Forms apps. http://chentiangemalc.wordpress.com/2013/03/18/sharpdevelop-rt-edition-beta-code-windows-forms-directly-on-windows-rt/