huakunyang / SummerTTS

SummerTTS 是一个基于C++的独立编译的中文和英文语音合成项目,可以本地运行不需要网络,而且没有额外的依赖,一键编译完成即可用于中文和英文的语音合成。SummerTTS is a standalone Chinese and English speech synthesis(TTS) project that has almost no dependency and could be easily used for Chinese TTS with just one key build out
401 stars 72 forks source link

How to compile DLL #33

Closed aiaimimi0920 closed 10 months ago

aiaimimi0920 commented 10 months ago

I attempted to compile using Ubuntu on WSL, I was able to generate .so files. However, I require DLL and LIB files for the Windows platform. If I modify CMAKE_CXX_COMPILER to x86_64-w64-mingw32-g++, it triggers compilation errors. What should I do? Any suggestions? @huakunyang

this is CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

project(tts)

#set(CMAKE_CXX_FLAGS " -O3 -w -std=c++11 ")
#set(CMAKE_C_FLAGS " -O3 -w -std=c++11 ")

set(CMAKE_CXX_FLAGS " -O3 -fopenmp -std=c++11 ")
set(CMAKE_C_FLAGS " -O3 -fopenmp -std=c++11 ")

#set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
#set(CMAKE_CC_COMPILER x86_64-w64-mingw32-gcc)

add_library(tts
        SHARED
        ${SOURCE_FILES}
        ./test/main.cpp
        ./src/tn/glog/src/demangle.cc
        ./src/tn/glog/src/logging.cc
        ./src/tn/glog/src/raw_logging.cc
        ./src/tn/glog/src/symbolize.cc
        ./src/tn/glog/src/utilities.cc
        ./src/tn/glog/src/vlog_is_on.cc
        ./src/tn/glog/src/signalhandler.cc
        ./src/tn/gflags/src/gflags.cc
        ./src/tn/gflags/src/gflags_reporting.cc
        ./src/tn/gflags/src/gflags_completions.cc
        ./src/tn/openfst/src/lib/compat.cc
        ./src/tn/openfst/src/lib/flags.cc
        ./src/tn/openfst/src/lib/fst.cc
        ./src/tn/openfst/src/lib/fst-types.cc
        ./src/tn/openfst/src/lib/mapped-file.cc
        ./src/tn/openfst/src/lib/properties.cc
        ./src/tn/openfst/src/lib/symbol-table.cc
        ./src/tn/openfst/src/lib/symbol-table-ops.cc
        ./src/tn/openfst/src/lib/util.cc
        ./src/tn/openfst/src/lib/weight.cc
        ./src/tn/processor.cc
        ./src/tn/token_parser.cc
        ./src/tn/utf8_string.cc
        ./src/engipa/EnglishText2Id.cpp
        ./src/engipa/InitIPASymbols.cpp
        ./src/engipa/alphabet.cpp
        ./src/engipa/ipa.cpp
        ./src/hz2py/hanzi2phoneid.cpp
        ./src/hz2py/Hanz2Piny.cpp
        ./src/hz2py/pinyinmap.cpp
        ./src/nn_op/nn_conv1d.cpp
        ./src/nn_op/nn_softmax.cpp
        ./src/nn_op/nn_layer_norm.cpp
        ./src/nn_op/nn_relu.cpp
        ./src/nn_op/nn_gelu.cpp
        ./src/nn_op/nn_tanh.cpp
        ./src/nn_op/nn_flip.cpp
        ./src/nn_op/nn_cumsum.cpp
        ./src/nn_op/nn_softplus.cpp
        ./src/nn_op/nn_clamp_min.cpp
        ./src/nn_op/nn_sigmoid.cpp
        ./src/nn_op/nn_conv1d_transposed.cpp
        ./src/nn_op/nn_leaky_relu.cpp
        ./src/platform/tts_file_io.cpp
        ./src/platform/tts_logger.cpp
        ./src/utils/utils.cpp
        ./src/modules/iStft.cpp
        ./src/modules/hann.cpp
        ./src/modules/attention_encoder.cpp
        ./src/modules/multi_head_attention.cpp
        ./src/modules/ffn.cpp
        ./src/modules/ConvFlow.cpp
        ./src/modules/DDSConv.cpp
        ./src/modules/ElementwiseAffine.cpp
        ./src/modules/random_gen.cpp
        ./src/modules/ResidualCouplingLayer.cpp
        ./src/modules/ResBlock1.cpp
        ./src/modules/WN.cpp
        ./src/modules/pqmf.cpp
        ./src/models/TextEncoder.cpp
        ./src/models/StochasticDurationPredictor.cpp
        ./src/models/FixDurationPredictor.cpp
        ./src/models/DurationPredictor_base.cpp
        ./src/models/ResidualCouplingBlock.cpp
        ./src/models/Generator_base.cpp
        ./src/models/Generator_hifigan.cpp
        ./src/models/Generator_MS.cpp
        ./src/models/Generator_Istft.cpp
        ./src/models/Generator_MBB.cpp
        ./src/models/SynthesizerTrn.cpp)

target_include_directories(tts PUBLIC ./eigen-3.4.0
                                            ./src/tn/header
                                              ./include
                                              ./src/header)

set_target_properties(tts PROPERTIES
    OUTPUT_NAME "tts"
)
huakunyang commented 10 months ago

If you are using gcc/g++ or clang on WSL Ubuntu, you will not meet the compile issue, i have tested the build with gcc on WSL Ubuntu.

If you are using mingw32, and meet the issue of missing DLLs, which seems the issue of compiling with Windows toolchain, so far, the project can not pass build with Windows toolchain, including the VS and possibly mingw32, which has been tracked by other issue that has been raised before, it is not resolved yet.

So, in summary, you could just use gcc/g++ or clang on WSL Ubuntu, for the build failure with mingw32, it is more related with Windows toolchain build, tracked by another issue and I will closed this one.

aiaimimi0920 commented 10 months ago

It is true that there is no compilation problem with using gcc, but I hope that the file is dll is not so file, because I want to call this dynamic library on windows.

Hope this problem will be solved soon

Thank you for your prompt reply