How to configure and use GCC compiler to Generate dll fille

Akash Chandrasekaran 20 Reputation points
2023-06-14T09:58:17.4533333+00:00

HI,

I want to configure Visual Studio with the GCC compiler for dll file generation. I have googled enough about creating this environment but could not able to find an appropriate solution.

I have an existing environment in which I create a C++ empty project and configured it accordingly but it uses the default visual studio compiler there is no option to change the compiler in the project properties.

In the platform toolchains, no GCC compiler is listed. only the default visual studio compiler is available.

Can anyone support me on how to add the GCC?

Developer technologies | C++
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. Minxin Yu 13,501 Reputation points Microsoft External Staff
    2023-06-15T03:18:14.3466667+00:00

    Hi,

    You need to install CMake tools in Visual Studio.
    User's image

    Create CMake project.

    enter image description here

    In default CMakePreset.json file Modify: "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++"

    User's image

    Add content in the CMakeList file.

    # CMakeList.txt : CMake project for CMakeProject1, include source and define
    # project specific logic here.
    #
    
    # Add source to this project's executable.
    add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h")
    
    if (CMAKE_VERSION VERSION_GREATER 3.12)
      set_property(TARGET CMakeProject1 PROPERTY CXX_STANDARD 20)
    endif()
    
    # TODO: Add tests and install targets if needed.
    
    
    add_library(YourLibraryName SHARED "Header.h" "Header.cpp")
    
    set_target_properties(YourLibraryName PROPERTIES LIBRARY_OUTPUT_DIRECTORY "")
    
    install(TARGETS YourLibraryName DESTINATION "")
    

    Click the icon to switch to CMake View.

    enter image description here

    enter image description here

    Right click the project->Build ALL.

    User's image

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.