- 1 year ago
How to compile googletest application for multiple files on windows using mingw64 with msys? [duplicate]
To compile a googletest application for multiple files on Windows using Mingw64 with MSYS, you can follow these steps:
Install Mingw-w64 with MSYS2 on your Windows machine.
Download the latest version of googletest from the official website and extract the files to a directory on your computer.
Create a new directory for your project, and copy the source files for your application into this directory.
Open the MSYS2 terminal and navigate to the directory where your project files are located.
Type the following command to compile your project files with the g++ compiler and link to the googletest library:
cssg++ -o test.exe -I<path-to-googletest>/include -L<path-to-googletest>/lib -lgtest -lgtest_main file1.cpp file2.cpp test.cpp
Replace
<path-to-googletest>
with the path to the directory where you extracted the googletest files, and replacefile1.cpp
,file2.cpp
, andtest.cpp
with the names of your project files.Press enter to run the command. If there are no errors, the compiler will create an executable file called
test.exe
in your project directory.Run the executable file by typing
./test.exe
in the MSYS2 terminal. The output of the tests will be displayed in the terminal.
Note that the above command assumes that you have all the necessary header files and libraries in the correct locations. If you receive errors about missing files, check that the paths to the include and library directories are correct.