简体   繁体   中英

DLL compiled in Windows 8 doesn't work in Windows 7

I got a program that use a .dll compiled on Windows 8. When I move the program and its .dll to Windows 7, the program crashes. It must be because of DLL compilation configuration I guess.

Below is part of the header file of the .dll

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

    void myFunc(void);

#ifdef __cplusplus
}
#endif

I tried Dependency Walker but dont understand it. In Windows 8, the dll has some missing dependencies but working well. In Windows 7, the dll missing dependencies is different

The program is compiled using TDM MinGW (it has to) while the DLL is compiled using Visual Studio 2013

Small wonder. Changes in the C++ language tend to force ABI differences (libraries aren't compatible anymore). And the operating systems are also (somewhat) different...

The name mangling process C++ uses to support class membership and function overloading differs between compilers. It is never guaranteed (and is in fact unlikely) that C++ symbols in a DLL written in one compiler will match the symbols generated in a different compiler.

See this on name mangling for details. Ultimately whatever the actual cause of the crash, the use of different compilers for the DLL and application code is probably unsafe.

You need either to use the same compiler throughout, or provide a DLL API with C linkage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM