Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I put my tests in a library and Google Test doesn't run them - GCC 4.8 #481

GoogleCodeExporter opened this issue Jul 28, 2015 · 3 comments


Copy link

@GoogleCodeExporter GoogleCodeExporter commented Jul 28, 2015

I have the reference project at

Just do:

    mkdir build
    cd build
    cmake ../

This does not execute any test cases in my local environment. This seemed to 
work on, so I was wondering if this is some GCC / environmental 
issue. My GCC is:

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' 
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-4.8 --enable-shared --enable-linker-build-id 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls 
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug 
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap 
--enable-plugin --with-system-zlib --disable-browser-plugin 
--enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home 
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic 
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu 
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 

Original issue reported on by on 5 Dec 2014 at 6:20

Copy link
Contributor Author

@GoogleCodeExporter GoogleCodeExporter commented Jul 28, 2015

Make sure the *_test libraries are actually linked into the final binary.
The linker might be excluding them because you are not using any symbol from it 
on you main file.
That is for VC++, but it applies to gcc also. I think --whole-archive can be 
used for gcc to force the library to be linked.

Original comment by on 5 Dec 2014 at 7:33

Copy link
Contributor Author

@GoogleCodeExporter GoogleCodeExporter commented Jul 28, 2015

You were right: The *_test libraries weren't linked to the final binary. It 
wasn't a CMake specific error, GCC just won't link unreferenced libraries. The 
--whole-archive flag doesn't work either - You have to use --no-as-needed. 

Thanks for all your help. I'll probably introduce fake dependencies to make it 
work in a cleaner way.

Shouldn't this information be added in the FAQ? Anybody upgrading to the newer 
compiler should face this.

Original comment by on 6 Dec 2014 at 7:27

Copy link
Contributor Author

@GoogleCodeExporter GoogleCodeExporter commented Jul 28, 2015

Original comment by on 8 Dec 2014 at 2:47

  • Changed state: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant