Professional Documents
Culture Documents
Build GoogleTest 1.10.0 Dari Source Code - Linux Centos79
Build GoogleTest 1.10.0 Dari Source Code - Linux Centos79
Build GoogleTest 1.10.0 Dari Source Code - Linux Centos79
9 64 Bit
https://stackoverflow.com/questions/13513905/how-to-set-up-googletest-as-a-shared-library-on-linux
https://www.programmersought.com/article/79594784118/
Tools :
Tulis lagi perintah cmake tapi dengan opsi –DBUILD_SHARED_LIBS=OFF untuk membuat static library.
Jika sudah lakukan kompilasi lagi
Hasil akhirnya tampil seperti pada gambar, berisi file2 .a (static library) & .so (dynamic library)
5. Contoh Kode
#include <gtest/gtest.h>
return a + b;
TEST(TesJumlah, HandleInputBukanNol) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Tulis kode yang ada di gambar, kemudian compile
Tampil error gtest/gtest.h No such file or directory yang berarti compiler tidak gagal mendeteksi file tsb
Tulis –lgtest
Setting di mode Debug & Release
Di Search Directories Compiler : Masukkan lokasi file2 header GoogleTest dengan klik tombol Add
(geser ke bawah supaya tombolnya kelihatan). Jika ada pertanyaan Keep this as a Relative Path ? pilih
No
Setting di mode Debug & Release
Di Search Directories Linker : Masukkan lokasi file2 library GoogleTest dengan klik tombol Add (geser
ke bawah supaya tombolnya kelihatan). Jika ada pertanyaan Keep this as a Relative Path ? pilih No
7. Coba Lagi
Selesai