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

Closed
GoogleCodeExporter opened this Issue Jul 28, 2015 · 3 comments

Comments

Projects
None yet
1 participant
@GoogleCodeExporter
Contributor

GoogleCodeExporter commented Jul 28, 2015

I have the reference project at https://github.com/tinkerbeast/myJunk.

Just do:

    mkdir build
    cd build
    cmake ../
    make
    ./run_tests


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

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' 
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs 
--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-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 
--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 
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 

Original issue reported on code.google.com by rishin.g...@gmail.com on 5 Dec 2014 at 6:20

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Jul 28, 2015

Contributor
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.
See 
https://code.google.com/p/googletest/wiki/Primer#Important_note_for_Visual_C++_u
sers
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 sbe...@google.com on 5 Dec 2014 at 7:33

Contributor

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.
See 
https://code.google.com/p/googletest/wiki/Primer#Important_note_for_Visual_C++_u
sers
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 sbe...@google.com on 5 Dec 2014 at 7:33

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Jul 28, 2015

Contributor
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 rishin.g...@gmail.com on 6 Dec 2014 at 7:27

Contributor

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 rishin.g...@gmail.com on 6 Dec 2014 at 7:27

@GoogleCodeExporter

This comment has been minimized.

Show comment
Hide comment
@GoogleCodeExporter

GoogleCodeExporter Jul 28, 2015

Contributor

Original comment by sbe...@google.com on 8 Dec 2014 at 2:47

  • Changed state: Done
Contributor

GoogleCodeExporter commented Jul 28, 2015

Original comment by sbe...@google.com 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