6

I've managed to install Google Test according to this.

My problem is the following: I have to test projects which are being developed for an embedded software with a 32-bit operating system, so I need to reconfigure Google Test from 64-bit.

With the old 1.7.0 version it is know that the solution was this:

autoreconf -fvi
./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
make

This is how I tried now with the new version:

cd home/CWD/googletest/googlemock
autoreconf -fvi
./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"

cd home/CWD/googletest/googletest
autoreconf -fvi
./configure --build=i686-pc-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"

cd ..
mkdir googletest_build
cd googletest_build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/me/googletest ../googletest
make
make install

Did this, because I could not find configure files anywhere else but results shown in the terminal were the same as with the 1.7.0 version's reconfiguration.

However after using:

make UTEST=yes project_Name

I get this:

Linking... project_Name
GTEST_LDFLAGS=-L ../../googletest//lib/ -lpthread -lgtest -lgtest_main -lgmock -lstdc++!
/usr/bin/ld: skipping incompatible ../../googletest//lib//libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libgtest.a when searching for -lgtest
/usr/bin/ld: skipping incompatible //usr/lib/libgtest.a when searching for -lgtest
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: skipping incompatible ../../googletest//lib//libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: skipping incompatible //usr/lib/libgtest_main.a when searching for -lgtest_main
/usr/bin/ld: cannot find -lgtest_main
/usr/bin/ld: skipping incompatible ../../googletest//lib//libgmock.a when searching for -lgmock
/usr/bin/ld: cannot find -lgmock
collect2: error: ld returned 1 exit status

The projects env variables are set to 32-bit in the makefile, so that shouldn't be the problem.

Looking at the error message I am thinking: Is it my gcc version?

2 Answers 2

5

To build 32-bit googletest using my answer that you have referred to just follow the same procedure but instead of running:

cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/me/googletest ../googletest

run:

cmake -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_INSTALL_PREFIX:PATH=/home/me/googletest ../googletest

If you are making even a personal installation of 32-bit googletest on a 64-bit host it would be a good idea to make it obvious that it is 32-bit, e.g. by using the like of:

-DCMAKE_INSTALL_PREFIX:PATH=/home/me/googletest_32
0
2

We build google test with our applications itself. We did not use any pre build library, we simply include the needed stuff in our build toolchain like this fragment in the Makefile shows:

include /opt/foreign_components/gmock-1.7.0/gmock.mk

OBJ_SERI_BASIC = \
        $(GMOCK_OBJ) \
        $(COMPONENT_HOME_SERI)/unittest/src/test_virtual.o \
        $(COMPONENT_HOME_SERI)/component/name_value_pair.o

and the gmock.mk contains:

GMOCK_PATH=$(HOME)/foreign_components/gmock-1.7.0

GMOCK_OBJ= \
       $(GMOCK_PATH)/fused-src/gmock_main.o \
       $(GMOCK_PATH)/fused-src/gmock-gtest-all.o

GMOCK_INCLUDE=\
          -I$(GMOCK_PATH)/fused-src/gmock/ \
          -I$(GMOCK_PATH)/fused-src

So any flags and changes to the build will also be affect the test framework. So we build it with different compilers, targets and also for 64 and 32 bit on various platforms.

5
  • Interesting to know for 1.7.0, so +1 from me. Still I've been told here that 1.7.0 is an old version, and should use the new distribution now. First I will try @Mike Kinghan's solution, but many thanks for this explanation as well! :)
    – MattSom
    Jul 27, 2016 at 8:33
  • @MattSom: I see no reason why this solution will not work with current "versions". A little remark: "+1"? can't see it :-)
    – Klaus
    Jul 27, 2016 at 8:42
  • I see none as well for now, because I'm really a rookie with Google Test. Mike has just advised it, and I want to follow that way and try it, until it seems I need another perspective. About upvote: It is saved there, but it says it won't be displayed, until I have 15 reputation points.
    – MattSom
    Jul 27, 2016 at 9:10
  • 1
    @MattSom: The method to directly use the source in the project is mentioned in the README.md of the project as first solution. That is simply adding two files to your build. No further need of any precompilation, library configuration and installing. Simply two files adding... Give it a try :-)
    – Klaus
    Jul 27, 2016 at 9:12
  • Okay. The project I need to test piece by piece is a little vast in code quantity, but does have makefiles naturally, so I will certainly try every solution, just for curiosity if nothing else.
    – MattSom
    Jul 27, 2016 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.