DEV-CPPMINGW32 Environment Introduction (5)

xiaoxiao2021-03-06  93

DEV-CPP / MINGW32 Environment Introduction (5)

Review:

The above "DEV-CPP / MINGW32 environment introduction (4)" We introduced how to use a static connection library. Today we introduce how to make your own MingW32 static link library. As for the static connection library under Win32, I want to be familiar with Win32, I should be very clear how to make it. So we don't introduce it here.

Chapter 8 makes your own static link library

This is Chapter VII, and the eight numbers like many people like it. me too. (I feel so superstition.) This chapter we have to make a static link library, I believe that you will be very happy. First of all, I will briefly introduce the role of the static link library. We know that the C / C program generates the process of target code, write code, compile code, connection code, and generate the target code. When connecting the code, the compiled binary code is connected to the target code. However, sometimes it. We want the program to import the necessary code, and do not want to import useless code into our program. What should we do? Very simple, use a static connection library. Use it we can implement the purpose of importing the function used in the program. Let's take a step by step to do a static link library and learn how to use it. We must write a code first, you can use DEVs to use Notepads to use any text editor you like. As I prefer VI or Emacs as the usual text editor. It's far away, and now I'm passing. We write down the following code.

//Helloworld.c

#include

Void HelloWorld (Void) {Printf ("Hello World");}

The C-code should be very familiar with the C code, then the classic Hello World is good to make me miss. We started to be generated after saving for helloworld.c. First of all, let's compile helloworld.c first

gcc -c helloworld.c -o helloworld.o

This way we get a binary file helloWorld.o

Then we generate a static library.

Ar CQs Libhelloworld.a HelloWorld.o

This way our party is still a static link library. If there is a need to add another binary file name to a static link library. In addition, the generated static library file name must be Lib * .a

Ok, now let's use our library.

Next, in order to be able to use it, we write a next file.

//HelloWorld.hvoid HelloWorld (Void);

Then we start using the static library we just generated. Write a file of main.c.

//main.c

#include "HelloWorld.h"

INT main (void) {helloworld (); return (0);

Compile with GCC, assume that all of us are saved in the same directory here.

gcc -c main.c -o main.o

Then we connect the program.

gcc main.o -o main.exe -l "./" -lhelloworld

If we have successfully we get a main.exe file.

Enter main.exe or main in the console can appear Hello World.

Looking at the above article is very excited to generate your own static link library? In fact, I personally think that MingW32 generates a static link library to be simpler than VC. I don't know if you have this feeling.

Of course, if you want to use a static connection library under DEV, it is also possible. Method I have said in the previous chapter. Just, if you want to use your library, you must set the path.

Just add -l "your folder for your library" in the connector parameter or save your library to the lib directory in the DEV installation directory.

Ok, this article introduces here. If you have any questions, you can leave a message here. Ask the eucalyptus:

This article is actually really like, not the article likes, but it is very like. I don't know how you think. Here is a method of generating a static library that feels simpler than the VC generated. In fact, it is necessary to generate a dynamic connection library under the GCC's Linux platform. It is not known to be simpler than the VC. If the best platform for development in Win32 is Win2000, then the platform used to develop in the X86 system is too linux. The content of this chapter may have some strangers to many of the programmers. I really worry that you will encounter problems in practice, so I still hope that you will ask here when you encounter difficulties. Finally, my famous saying: Whether it is a procedure or thinking through constant exchanges, it can be more perfect. (I have seen "Ancient Ren Minglang"? The protagonist always likes to publish a view: I am an ancient 畑 畑 三.. I feel like him. However, this is indeed a good film. At least a lot of exploration Both good, there is no extra plot, no you, my my love. Purely taken from a case of a way of solving the case. Recommend you to see.)

Studio software development group

Beidou Ringjun (Huang Yucui)

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

New Post(0)