Dev-CPP/mingw32 Environment Introduction (4)

Source: Internet
Author: User

Dev-CPP/mingw32 Environment Introduction (4)

Review above:


The previous introduction to the dev-CPP/mingw32 environment (3) describes the simple methods for debugging programs using GDB. This article will show how mingw32 uses the static Connection Library. Although the release time of this article is indeed a little slow. But I think you should be able to understand.

Chapter 7 use static Connection Library in your program


In Windows, you may be familiar with objects ending with OBJ and Lib. These files are binary files and static connection Libraries under Win32. However, in mingw32, there are some special things that I have introduced in the first chapter. They are O and. It's strange. But we only need to know how to use it here. More information is beyond the scope of this article.
Let's take VC as an example. You know that when using a static library in VC, you should select the imported static library when connecting to the program. The parameter is the full name of the static library. For example, winmm. Lib is different in mingw32. You can use-lwinmm as the parameter. -Lwinmm means to import the static Link Library libwinmm.. Are you confused? Next we will introduce the usage and significance in Dev.
Start Dev and create a new project. Select project> project properties. (If you use the new look icon, the project property is a shield icon .) Then, select the parameters tab. Enter the parameters you want in the connector text box, such as-lwinmm. As for the delimiter, you can use spaces or press Enter. However, I personally recommend that you press Enter. If it goes well, your interface will look like.


Of course, if you want to use *. Lib, you only need to fill in the file name directly. Like winmm. Lib. Of course, you can use an absolute path.
Next we will look at the format of the static Connection Library. Of course, we do not analyze the file format, but the call format. Generally, the file name of the static library is lib *. A, where * represents any character. In our call, we do not need to use all the file names, but only need to use the * content. Just like calling the libwinmm. A static library, you only need to add the parameter-lwinmm during the connection. The preceding lib and later. A are not required. If not. Check the lib directory in the dev installation directory. There are many static connection Libraries under Win32. Analyze the file name and call method.
Finally, let's take a look at the usage of the static Connection Library.
What should I do? Write a music player on the console. Of course, it is just simple to play music, and the path does not support Chinese. This is just to familiarize yourself with the use of static libraries.
Create a console project, and then write the following code in the main. C code.

// Main. c
# Include <windows. h>
# Deprecision 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 );

Mcisendstring (filename, 0, 0 );

Mcisendstring ("play media", 0, 0 );

System ("pause ");
}
Else
{
Printf ("play.exe musicfilename ");
}

Return 0;

}
// Main. C end

Then, enter-lwinmm In the connector parameters of the project properties. Start compilation. If it succeeds, our program will be compiled successfully. You can also play some commonly used music files. Happy.

Now, we will use this example to complete this chapter.

Question:
As I have been busy recently, I have changed the original two chapters into one. Forgive me. The next chapter describes how to create a static Connection Library for mingw32. Coming soon. I hope you can give more comments. This is because it can be improved through continuous communication, both in terms of procedures and ideas.

 

Studio software development team

Dipper (Huang yaokui)

 

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.