You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MingGWx64编译DLL时出现timeGetTime入口点缺失问题求助

Fixing the Missing timeGetTime Entry Point When Compiling a DLL with MinGW-w64

Hey there, let's work through this issue step by step. That missing entry point error happens because timeGetTime lives in a library MinGW doesn't link automatically, plus there are a couple of tweaks we can make to your code and build command to get things working.

The timeGetTime function is part of the Windows Multimedia Library (winmm.dll). MinGW-w64's linker doesn't include this library by default, so you need to explicitly tell it to link against it. Update your compile command to add the -lwinmm flag:

gcc -shared -o evil.dll evil.cpp -DWIN32_LEAN_AND_MEAN -lwinmm

2. Clean Up Your DLL Export Code

Your code snippet cuts off, but it looks like your DllExport marker might be in the wrong place, and it's good practice to separate function declarations from definitions for clarity. Here's a corrected version of your code that ensures proper export and includes an optional (but recommended) DllMain:

#include <windows.h>
#define DllExport __declspec(dllexport)

// Declare the exported function first
DllExport int fireMyLaser();

int fireMyLaser() {
    WinExec("calc", 0);
    return 0;
}

// Optional: Add DllMain for initialization/cleanup (common in DLLs)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
    switch (fdwReason) {
        case DLL_PROCESS_ATTACH:
            // Put any setup code here if needed
            break;
        case DLL_PROCESS_DETACH:
            // Put cleanup code here if needed
            break;
    }
    return TRUE;
}

3. Verify Your MinGW-w64 Setup

Double-check that your MinGW-w64 installation is complete—sometimes missing library files can cause odd linker/loader errors. If you installed it via a package manager like MSYS2, make sure you've updated all packages recently.

Why This Happens

Unlike functions in core libraries like kernel32.dll (which MinGW links automatically), timeGetTime is part of a secondary multimedia library. Without the -lwinmm flag, the linker doesn't include references to winmm.dll, so when your EXE tries to load the DLL, it can't find the timeGetTime entry point.

内容的提问来源于stack exchange,提问作者Morgan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:15:25