Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I never could get this to work as a static library, but it's working as a DLL.</p> <p>First, I had to build Google Test as a DLL. I did not have any success getting this to work in Visual Studio, so I just used mingw32-make. You can use the Makefile provided in the source, making the following changes:</p> <pre><code>gtest-all.o : $(GTEST_SRCS_) $(CXX) $(CPPFLAGS) -DGTEST_CREATE_SHARED_LIBRARY=1 -I$(GTEST_DIR) $(CXXFLAGS) -c \ $(GTEST_DIR)/src/gtest-all.cc gtest_main.o : $(GTEST_SRCS_) $(CXX) $(CPPFLAGS) -DGTEST_CREATE_SHARED_LIBRARY=1 -I$(GTEST_DIR) $(CXXFLAGS) -c \ $(GTEST_DIR)/src/gtest_main.cc gtest.dll : gtest-all.o $(CXX) -shared -o $@ $^ -Wl,--out-implib,gtest_dll.lib gtest_main.dll : gtest-all.o gtest_main.o $(CXX) -shared -o $@ $^ -Wl,--out-implib,gtest_main_dll.lib </code></pre> <p>Then, when compiling your test project, you must:</p> <ul> <li>Define GTEST_LINKED_AS_SHARED_LIBRARY=1</li> <li>Set a library reference to either gtest_dll.lib or gtest_main_dll.lib.</li> <li>Paste gtest.dll or gtest_main.dll in the same directory as your executable.</li> </ul> <p>(My understanding is that you use gtest_main only if you are NOT providing your own main() function.)</p> <p>Here is a sample Qt pro file based on the one I have this is (finally!) working:</p> <pre><code>DEFINES += GTEST_LINKED_AS_SHARED_LIBRARY=1 SOURCES += main.cpp MyClassTests.cpp INCLUDEPATH += ../path/to/gtest/includes LIBS += -L../path/to/gtest/libraries -lgtest_dll \ -L../ClassLibrary/bin -lMyClass CONFIG += console </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload