Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows compile #35

Open
aiaimimi0920 opened this issue Jan 6, 2024 · 3 comments
Open

windows compile #35

aiaimimi0920 opened this issue Jan 6, 2024 · 3 comments

Comments

@aiaimimi0920
Copy link

aiaimimi0920 commented Jan 6, 2024

@huakunyang
First of all, thank you very much for creating this project

Because the question I asked a few days ago was not effectively resolved (#33) , I did some research on Windows related compilation

Let me show you the results. This is the effect of compiling this project into the game

2024-01-06.18-04-05.mp4

I will mainly talk about the parts that need to be modified in Windows compilation :

  1. Compilation issues with glog and gflags: The compilation is not proceeding smoothly because your project code is compiled using referenced files. However, Windows compilation requires one of the files specific to Windows. This necessitates some adjustments to the compilation code; otherwise, you will encounter the error mentioned in this link: Successfully run on Windows #5 (comment). If you simply use #include "windows/port.h", you will notice similar errors in other files. The final solution is to treat it as a library compilation and then compile the project, linking it with this library.

  2. Compilation errors and crashes caused by Openfst: Skipping the steps of identifying the problem, the fundamental reason is that the MSVC toolchain, which uses the cl compiler, cannot correctly recognize FST types (such as StdVectorFst), leading to crashes. This is because all type definitions are registered through fst-types, but MSVC cannot link smoothly, resulting in crashes. However, if you adjust the compiler to clang-cl, you won't encounter this problem.

  3. Missing definitions:
    3.1. M_PI:

#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif

3.2. unistd.h, dirent.h, getopt.c, getopt.h: You need to replace some include code in certain files, such as tts_file_io.cpp, etc.
code.zip

After these adjustments, you should be able to successfully compile the project.

=============================================================================
感觉中国人很多,再讲讲中国话

  1. glog 和 gflags 无法顺利编译:因为你的项目代码中使用的是引用文件的形式进行的编译,但是windows编译需要的是其中一个windows下的文件,这就需要对于编译代码进行一些调整,否则就会出现这个报错Successfully run on Windows #5 (comment) . 如果你单纯的使用# include “windows/port.h” 你会发现其他文件也开始出现相似的报错 :
    最后的解决方法:我将其看作一个库编译,然后在编译项目的时候再连接这个库的lib和头文件从其中获得代码编译成dll就可以了

  2. Openfst 引发的编译报错和崩溃:省略发现问题的步骤,根本原因是因为:MSVC工具链使用的cl编译器无法正确的识别FST类型(如StdVectorFst)导致崩溃,因为所有的类型定义是通过fst-types 注册的,但是msvc无法顺利的link,所以会崩溃。但是:如果你将编译器调整成clang-cl就不会有这个问题!

  3. 缺失定义:

    1. M_PI :
    #ifndef M_PI
    #define M_PI 3.1415926535897932384626433832795
    #endif
    
    1. unistd.h , dirent.h, getopt.c , getopt.h : 你需要替换一些文件的include代码,比如tts_file_io.cpp 等等
      code.zip

然后你应该就能编译成功项目了

@huakunyang
Copy link
Owner

Thanks a lot for your working on building in Windows, which is asked by many users, however, I have not done it yet due to lack of time, your working is excellent, and I should integrate your change into this project when I have time, thanks again, great job :-)

非常感谢你的改动,在Windows上的编译一直是很多人想要的,我苦于没有时间来作,你的改动解决了Windows上的编译,非常感谢,我有空的时候,会把你的改动集成上去,谢谢。

@aiaimimi0920
Copy link
Author

aiaimimi0920 commented Jan 6, 2024

@huakunyang
因为我是为了我的项目制作的内容:https://github.com/aiaimimi0920/godot-tts

所以我无法直接为你提供pr,需要你自己做一定的修改,或者可以粘贴我项目中的thirdparty/SummerTTS文件,
注意我将openfst更新了版本,你引用的库有一个相关的更新,我采用了更新,用老版本应该也没问题

  1. 关于我说的glog和gflags编译的问题,你需要自行实现,我是通过github的action实现的,因为我整个项目是通过github的action自动打包的:https://github.com/aiaimimi0920/godot-tts/actions/runs/7431890578 相关的build代码你可以参考一下:https://github.com/aiaimimi0920/godot-tts/blob/main/.github/workflows/windows_builds.yml
    我本来想提供一个pr,但是就是因为感觉删除glog和gflags使用github的action进行编译不符合大多数人的用例,所以我就没有提供pr了,理论上你可以通过研究一下glog和gflags的cmakelists文件明白其是如何完成在windows下进行不同的编译的,然后把它集成进入项目。我研究了,然后感觉太复杂了,看不懂,我放弃了,所以最后就变成先编译glog和gflags然后再链接编译出来的lib文件的形式

  2. Openfst 引发的编译报错和崩溃,注意一定要使用clang-cl 编译这个模块,要不总是会编译报错,这一步骤卡了我很久

  3. 缺失定义的替换应该很简单,只要简单替换成windows的实现就可以,你可以根据

#ifdef _WIN32
xxx
#else
xxx
#endif

的形式提供条件编译

  1. 至于其他部分我相信都很好解决

根据我的做法你应该能编译成功,我已经可以稳定的编译成功我的插件,所以提供windows版本的编译结果理论上应该是没有任何问题的

@huakunyang
Copy link
Owner

@huakunyang 因为我是为了我的项目制作的内容:https://github.com/aiaimimi0920/godot-tts

所以我无法直接为你提供pr,需要你自己做一定的修改,或者可以粘贴我项目中的thirdparty/SummerTTS文件, 注意我将openfst更新了版本,你引用的库有一个相关的更新,我采用了更新,用老版本应该也没问题

  1. 关于我说的glog和gflags编译的问题,你需要自行实现,我是通过github的action实现的,因为我整个项目是通过github的action自动打包的:https://github.com/aiaimimi0920/godot-tts/actions/runs/7431890578 相关的build代码你可以参考一下:https://github.com/aiaimimi0920/godot-tts/blob/main/.github/workflows/windows_builds.yml
    我本来想提供一个pr,但是就是因为感觉删除glog和gflags使用github的action进行编译不符合大多数人的用例,所以我就没有提供pr了,理论上你可以通过研究一下glog和gflags的cmakelists文件明白其是如何完成在windows下进行不同的编译的,然后把它集成进入项目。我研究了,然后感觉太复杂了,看不懂,我放弃了,所以最后就变成先编译glog和gflags然后再链接编译出来的lib文件的形式
  2. Openfst 引发的编译报错和崩溃,注意一定要使用clang-cl 编译这个模块,要不总是会编译报错,这一步骤卡了我很久
  3. 缺失定义的替换应该很简单,只要简单替换成windows的实现就可以,你可以根据
#ifdef _WIN32
xxx
#else
xxx
#endif

的形式提供条件编译

  1. 至于其他部分我相信都很好解决

根据我的做法你应该能编译成功,我已经可以稳定的编译成功我的插件,所以提供windows版本的编译结果理论上应该是没有任何问题的

再次表示感谢,我会在有空的时候把你的改动合进去。其他想在Windows上使用的,也可以参考这位同学的修改,非常细致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants