Skip to content

全新安装提示缺少 dll 文件 #24

@KumaTea

Description

@KumaTea

如题,全新安装 2.2.0 后启动提示:

由于找不到 libgcc_s_seh-1.dll,无法继续执行代码。重新安装程序可能会解决此问题。

由于找不到 libstdc++-6.dll,无法继续执行代码。重新安装程序可能会解决此问题。
Screenshot 2023-08-10 215108

在网上下载上述2个文件后,提示

由于找不到 libwinpthread-1.dll,无法继续执行代码。重新安装程序可能会解决此问题。

在网上下载上述文件后,提示 0x0000007b

Screenshot 2023-08-10 215051

没接触过 C++, 搜索后提示可能是运行库未编译为静态


临时解决方案

修改 launcher.cpp

#include <iostream>
#include <stdio.h>
#include <direct.h>
#include <windows.h>
-#include<sys/stat.h>
+#pragma comment(lib,"user32.lib")  // https://stackoverflow.com/a/10844369/10714490
using namespace std;

HWND hwnd = GetForegroundWindow();  //获取程序启动时的窗口

void HideWindow() {
	if (hwnd) {
		ShowWindow(hwnd, SW_HIDE);	//设置指定窗口的显示状态
	}
}

void ShowWindow() {
	if (hwnd) {
		ShowWindow(hwnd, SW_SHOW);	//设置指定窗口的显示状态
	}
}

bool checkIfFileExists(const char* filename){
-   struct stat buffer;
-   int exist = stat(filename,&buffer);
-   if(exist == 0)
-       return true;
-   else  
-       return false;
+   DWORD dwAttrib = GetFileAttributes(filename);
+   return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}

int main()
{   
    HideWindow();
    // ShowWindow(); // If debug
    char buffer[16384]; 
-   getcwd(buffer, 16384);
+   _getcwd(buffer, 16384);
    string root = buffer;
    string pyBin = root +"\\toolkit";
    string GitBin = root +"\\toolkit\\Git\\mingw64\\bin";
    string env_cmd = "PATH="+pyBin+";"+pyBin+"\\Scripts;"+pyBin+"\\Lib;"+GitBin+";%PATH%";
    cout << env_cmd.c_str() << endl;
    _putenv(env_cmd.c_str());
    char buf[8192]; //缓冲区
    string p_cmd = "cd /d "+root+" && python -m gui";
    cout << p_cmd.c_str() << endl;
    // system(p_cmd.c_str());
-   FILE *fp = popen(p_cmd.c_str(),"r");
+   FILE *fp = _popen(p_cmd.c_str(),"r");
    if (fp == NULL) //判断管道是否打开成功
    {
        cout << "Fatal Error: Cannot open pipe" << endl;
        ShowWindow();
        return -1;
    }
    int ret = fread(buf, 1, sizeof(buf), fp); //读取显示结果
    if (ret > 0) //判断是否读取成功
    {
        cout << buf << endl; //输出显示结果
-       pclose(fp);
+       _pclose(fp);
        // ShowWindow();
        return 0;
    }
    else
    {
-       pclose(fp);
+       _pclose(fp);
        ShowWindow();
        cout << "Fatal Error: Program Run Failure." << endl;
        cout << "Running automatic error checking..." << endl;
        if (checkIfFileExists((pyBin+"\\python.exe").c_str()) == false){
            cout << "Possible reason: toolkit is not installed. Please check if you downloaded the correct file or if you cloned the submodule." << endl;
        }
        else{
            cout << "No reason founded. Please submit your error message." << endl;
        }
        system("pause");
        return -1;
    }
    ShowWindow();
    return 0;
}

然后安装 VS Build Tools, 安装 Windows 11 SDK 以及 MSVC C++ build tools, 使用 cl /EHsc launcher.cpp 编译

image

launcher.exe (for Windows 11 22621)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions