所以我試着用googletest庫(https://github.com/google/googletest)。首先,我用cmake的編譯它:在linux上編譯googletest程序openSUSE with g ++,make,cmakelists
[email protected]:~/documents/github/googletest/googletest/cmake> cmake ..
-- The CXX compiler identification is GNU 4.8.5
-- The C compiler identification is GNU 4.8.5
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: /usr/local/bin/python (found version "3.4.5")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marton/documents/github/googletest/googletest/cmak
e
[email protected]:~/documents/github/googletest/googletest/cmake> make
Scanning dependencies of target gtest
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 50%] Linking CXX static library libgtest.a
[ 50%] Built target gtest
Scanning dependencies of target gtest_main
[ 75%] Building CXX object CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[100%] Linking CXX static library libgtest_main.a
[100%] Built target gtest_main
,並試圖使用g ++編譯它,使:
Thu Mar 16; 22:45:19; marton;~/documents/github/fmi_summer_2017/chisleni_metodi ; $ g++ -isystem /home/marton/documents/github/googletest/googletest/include -L/home/marton/documents/github/googletest/googletest -pthread -lgthread 002.razd_razl.cpp -o test
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lgthread
collect2: error: ld returned 1 exit status
我不知道,如果這個錯誤是由於我的編譯器/發行,但我已經安裝了這些包:
GCC-32位gcc48-32bit的glibc-devel的,32位libasan0-32bit libatomic1-32bit libgomp1-32bit libitm1-32bit
所以我認爲lgtest是這個問題和作爲糟糕的編碼器我決定刪除它,結果是一個未定義函數,命名空間和變量的大名單。
所以我試過這個回購:(https://github.com/snikulov/google-test-examples)。 一切工作正常,這意味着問題不在我的編譯器,但回購是使用cmakelists。
我在做什麼錯,我需要做些什麼來編譯我的程序?
我知道法西斯怪人會倒下來,但我搜索谷歌,YouTube,gtest回購,並沒有任何解釋如何通過g ++編譯你的程序你的測試的解釋。那我在哪裏可以找到關於這方面的信息?
使用make或CMakeLists更好嗎?
您在哪裏找到用於構建測試的命令行?爲什麼你需要'gthread'(GLib線程)庫來進行測試? – Tsyvarev
如果通過gthread你的意思是-lgthread,我不確定它是否需要,但如果我嘗試編譯我的程序沒有它,我的終端得到充滿錯誤 – Hartun