| |

VerySource

 Forgot password?
 Register
Search
View: 877|Reply: 7

MinGW compiled DLL in the use of VC, experts help! !! !!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-11 14:30:01
| Show all posts |Read mode
Now write a dll with DEV-C ++, generate a static library file of .a and a dynamic library of .dll, then write a console program with DEV-C ++, and call the function of the dll by linking the above .a file , Ok, through.

Later in VC2003, the same console program also linked the .a file, called the .dll, compiled and passed, no problem, but reported an access violation when calling the function in the DLL during execution.

In VC2003, do not link the .a file, use LoadLibrary and GetProcAddress to load the functions in the .dll, and execute, OK, pass.

Why does an error occur when linking .a files in VC2003? Are .a files and VC writing dlls different in the format of generating .lib files? Then why does VC compile and link .a files without problems? How can I make Dev-C ++ DLLs call DLLs by linking .a files? (All functions to be called are more painful using GetProcAddress)
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-26 21:45:01
| Show all posts
The format is different.
The format of MS lib file and MinGW a file is different.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-29 23:45:01
| Show all posts
DLL
DEV-cpp's .a corresponds to .lib in vc++, they are different file formats,

Use LoadLibrary and GetProcAddress to load functions in .dll, which is a way to call functions using dynamic linking.
And using .lib or .a is to use static linking.

The mechanism for calling functions is different.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-30 00:00:01
| Show all posts
C++ things, generally so-called cross-platform, means that the program code can be compiled on multiple platforms.
The landlord can put the Dev-cpp DLL program into VC and recompile, and generate a .lib file for linking and calling.
Reply

Use magic Report

0

Threads

23

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-7-30 17:00:01
| Show all posts
Is there a way to generate .lib from .a?
Reply

Use magic Report

0

Threads

23

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-7-30 18:30:01
| Show all posts
Found the answer on the Japanese website, translate it later

MSVC からは MinGW ライブラリを呼び出すことは出ませんが、 週に DEF ファイルが手元にあるのですかききかききかききかききかきききかききかきらかきらるきらにせかきらるきにににあからきらきからせ
lib /machine:i386 /def:testdll.def

もし testdll.lib を持っているのであれば、MSVC で実行ファイルを作るのは取るに足らない動事です。
cl testmain.c testdll.lib
Reply

Use magic Report

0

Threads

23

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-7-30 19:00:01
| Show all posts
Basically it means that you can use the .def file you generated when compiling with mingw, and generate .lib through the LIB command that comes with vc
Assuming that the def generated with the .dll is testdll.def, use the following command line
lib /machine:i386 /def:testdll.def

You can generate testdll.lib, then you can statically link this dynamic library directly in vc in the future
cl testmain.c testdll.lib
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-31 03:15:01
| Show all posts
Upstairs, why are you looking for Japanese?
There is also a lot of English and Chinese information about exporting .lib files from dll: search for "dll to lib"

Create LIB function symbol input library for DLL without LIB:
http://www.vckbase.com/document/viewdoc/?id=613


-----------------
There are two kinds of .lib, one is static, which includes the actual code of the function, the other is the .lib generated by the DLL, which does not contain the code, but contains the link information of the DLL.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list