DEV-CPPMINGW32 Environment Introduction (4)

xiaoxiao2021-03-06  116

DEV-CPP / MINGW32 Environment Introduction (4)

Review:

The above "DEV-CPP / MINGW32 environment introduction (3)" describes a simple way to use the GDB debugger. In this article we will see how MingW32 uses a static connection library. Although it is indeed a bit slow in this paper. However, I think you should be able to understand.

Chapter VII uses a static connection library in your program

In Windows may be familiar with files ending with OBJ and LIB. These files are the binary and static connection libraries under Win32. But there are some special in MingW32, I originally introduced in the first chapter. They are O and A. Very strange. However, we just know how to use it. About more is not within the scope of this article. Let's take a VC as an example, you know that you want to use a static library in the VC to select the imported static library when the program is connected. The parameter is the full name of the static library. For example, WinMM.LIB but is somewhat different from mingW32. The parameter you use is -LWINMM. And -LWINMM means importing static link library libwinmm.a. Is it something wrong? Let's take a look at the use and significance in the DEV. First we start the DEV, create a new project. Then select Engineering -> Engineering Attributes. (If you use the New Look icon, the engineering property is a shield icon.) Then, select the Parameters tab. Enter the parameters you want in the text box of the connector, such as -lwinmm. As for the split, a space can be used or a carriage return. But I personally recommend the carriage return. If you are going well, your interface looks like a picture below.

Of course, if you want to use * .lib, you can fill in the file name directly. Just like WinMM.LIB. Of course, if you can use an absolute path. Let's take a look at the format of the static connection library. Of course, we are not analyzing from the file format, but from the call format. Usually the file name of the static library is lib * .a * indicates any character. And when we call, you don't need to use all the file names, just need to use * content. Just like calling libwinmm.a, we only need to add parameters when connecting - LWINMM. The front LIB and behind .a don't need it. If, don't understand. You can look at the lib directory in the DEV installation directory. There are many static connection libraries under Win32. It will be very clear about the file name and calling method. Finally, we combat the use of static connection libraries. What is it written? Write a music player on a console. Of course, just simply play music, and the path does not support Chinese. Here is just to be familiar with the use of static libraries. Create a new console project, then we write the following code in the main code of Main.c.

//main.c#include

#define max 255

INT Main (int Argc, char * argv []) {if (argc == 2) {char filename [max]; strcpy (filename, "open"); strcat (filename, argv [1]); strcat (filename, "Alias ​​Media"); McISendstring ("Close Media", 0, 0, 0);

McIndstring (filename, 0,0,0);

McISendstring ("Play Media", 0, 0, 0);

System ("pause");} else {printf ("Play.exe MusicFileName);

Return 0;

} // main.c end

Then we enter -lwinmm in the connector parameters of the engineering attribute. Start compilation. If we go well, our procedure will compile success. And you can play some common music files. Happy. Ok, this chapter we will end here with this example.

Ask the proud: Since I have been busy recently, the original two chapters changed to a chapter. please forgive. The next chapter will introduce how to establish a static connection library of MINGW32. Stay tuned. And I hope that you can give more comments. Because whether the procedure is still improving, it can be more improved through constant exchange.

Studio software development group

Beidou Ringjun (Huang Yucui)

转载请注明原文地址:https://www.9cbs.com/read-126378.html

New Post(0)