Develop portable applications that do not lock privileges

Source: Internet
Author: User
Article title: develop portable applications that do not lock privileges. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
With Xmingwin, you can generate Windows programs from the Linux server. This topic provides the method for setting Xmingwin and outlines the most important reasons for doing so.
  
Even if I use C, I still perform a lot of Window development on the Linux host. This server clinic column describes how to add mingw32-gcc source. c-o executable.exe to the regular gcc source. c-o executable command system and why you want to do so.
  
   Perform operations automatically on UNIX
Several articles in the most popular server clinic column in 2002 explain how to manage common desktop technologies from servers, including PDF and DOC files. In a sense, this is the goal of many products and books including WINE, VMware, and Linux in the Workplace. They all claim the ability to replicate common desktop technologies from Linux hosts. The References section below provides a reference on where these alternatives and recommendations are most applicable.
  
However, this topic will always be discussed from another perspective. The main point of this month is not to simulate Windows, but to use the development source code tool to automatically generate products that can be used on Windows. Mingwin (also known as Mingw and Mingw32) is short for MINimalist Gnu for WINdows (Gnu, the minimum requirement for WINdows). This description is suitable for it. Mingwin is a Windows-based development kit that can be roughly comparable to Visual C ++ or Borland's Delphi. Different from the latter two, Mingwin provides a UNIX-like environment in Windows. Because it is based on the standard GNU compiler gcc, Mingwin also supports C ++, Fortran, and other closely related languages. It does not provide an integrated development environment (IDE) with complex structures, which is common in Windows development environments. However, Mingwin has a wide range of toolboxes, including robust utilities that can perform basic development operations such as compilation and linking. Although all these operations have general UNIX characteristics, they are flexible and programmable.
  
Why is the server clinic so outdated? I often use applications that must run on the same level in UNIX, Windows, and other operating systems. It can increase my productivity and generate all deliverables from a single source code set. For example, by retaining the source code on a Linux server and performing automatic cross-generation, I ruled out "do you want to reboot? Are my file systems compatible? Has the project structure changed ?......" These problems seem to slow the development speed of some development laboratories. Changes made by each developer to my system either lead to production of all deliverables for all platforms or an explicit error message. This instant feedback prevents the vast majority of accidents such as "Ah, we thought everything went well last week.
  
If you want to pay more attention to development progress and spend less energy on the support platform, you will like Xmingwin. I will run "Mingwin run as a cross-generating application. (Mingwin runs as a cross-generated application .)" It is called Xmingwin. You should know that it is also spelled as "cross Mingw32", "Xmingw32", or other variants. The usage of this document is not well standardized. Recall that Mingwin is installed on a Windows host and provides a UNIX interface. Xmingwin cancels this interface so that the operation is the same as that on Windows, in addition, the output is the same as that prepared for Windows, but is generated on UNIX installation.
  
Installation is simple. I emphasize this here because when I first used Xmingwin, I encountered correct, confusing, and totally misleading suggestions. Start Installation in simple steps. To learn about the basic x86-based Linux information and start your Xmingwin career, please use a detailed package (see references for links ).
  
Decompress and decompress the package:
  
Listing 1. sequence of Xmingwin packet unpacking
INSTALLATION =/tmp/experiment
Cd $ INSTALLATION
Bunzip2 mingw-cross.tar.bz2
Tar xvf mingw-cross.tar
  
It is enough to start productive cross-generation. Although there are thousands of possible variants, they are very standard for Linux developers (linking based on different optimization levels, porting to another hardware type Linux, etc ), however, the basic Xmingwin installation requires a lot of effort.
  
   Use Xmingwin for cross-generation
Add the distribution version bin directory to your PATH. Some developers prefer a link or symbolic link scheme so that they can enter gcc at a command prompt and parse it into a full path, such as/tmp/experiment/bin/mingw32-gcc. My own preferred choice is to make gcc always mean a local compiler and explicitly call or configure the mingw32-gcc as needed.
  
The first test of the new installation should just ask for its version: mingw32-gcc-v. It may report similar information:
  
Gcc version 2.95.3 20010315 (release)
  
Next, try the standard "comprehensive test"-write:
  
Listing 2. minimum "hello, world" source code
# Include
Int main (int argc, char * argv [])
{
Puts ("It works! ");
}
  
Compile with the following command:
  
Listing 3. sample generation sequence of simple source code
WORKING =/tmp
INSTALLATION =/tmp/experiment
PATH = "$ PATH: $ INSTALLATION/bin"
Export PATH = $ PATH: $ INSTALLATION/bin
  
Cc-o $ WORKING/minimal. c
Mingw32-gcc-I $ INSTALLATION/mingw32/include-o $ WORKING/minimal.exe $ WORKING/minimal. c
  
This script provides the Linux application/tmp/minimal and its Windows counterpart/tmp/minimal.exe. After you transfer the latter to a convenient Windows host, you will find that it is executed like any other Windows application that performs well.
  
   Background
Now let's discuss the topic. The Xmingwin/bin directory contains not only the cross compiler, but also the cross linker, the cross library manager, and almost two dozen tools for common developer operations. With some practices, you may generate a Windows-based deliverable from the same Makefile that you are using, just as you are currently doing for Linux.
  
Since Colin Peters created the first Mingwin compiler in 1998, it has developed quite fast. At that time, his gcc version was running in the Cygnus environment. With Jan-Jaap van der Heijden re-hosting Mingwin as a local Windows application and extending Mingwin to include all GNU binutil and make, this development continues. later, mumit Khan has expanded these achievements to include more things unique to Windows, including better Win32api Association.
  
The GUI and Win32-specific features are a focus of Mingwin's attention. you can read more about this in the references (especially in Khan's article. Server clinics focus on applications that can work on Linux and Windows. I divide my development effort into roughly the same two halves, half of which is a portable "pure C", and the other half is the cross-developed Critcl.
  
Critcl is an attractive Tcl programming language extension. At the beginning, Critcl performed some operations for Tcl, which is roughly equivalent to Brian Ingerson's Inline for Perl: Allow "external" language (in this example, C, but in general, you can use SQL, assembler, or even a wider combination) to embed it into the source code of the host language. This provides many advantages that need to be described in a complete column in the future. The main point is that the Critcl creator Jean-clude Wippler has fully improved its creation, making cross-generation easier. The result is: no need to write the make file or determine the link parameters. a single source code library is enough to generate Tcl and C target code for the host and cross environment. Critcl allows me to automatically execute and complete challenging jobs, and its speed is much faster than the traditional "manual" method.
  
   Conclusion
I am a little confused: We will discuss more about Critcl in future columns. During this period, I am interested in whether Xmingwin provides you with as many benefits as I have. Does your DLL (Windows-specific dynamic loading and receiving) work properly for you? More specifically, is development in only advanced Linux-hosted languages (such as Python, Ruby, Tcl, Perl, and REBOL) as you wish? Have you ever seen a job like this: you know that the job is to be completed on the Linux server, but you do not know how to do it, or even what language to use? Please join the Scripting Clinic Forum (click the discussion at the top or bottom of this article) to share your experience.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.