I am trying to experiment with Google test with Maven. So, I installed it using this link. I then created dummyTest.cpp for testing and added it in pom.xml to execute the test. While I do mvn clean install, I am getting following error -
[INFO] 1 total files to be compiled.
[INFO] 1 total files to be compiled.
[INFO] Found 1 processors available
[INFO] Found 1 processors available
[INFO]
Starting Core 0 with 1 source files...
[INFO]
Starting Core 0 with 1 source files...
[INFO] Linking...
[INFO] Linking...
[INFO] Starting link {4.8.3 -L/usr/lib -Bdynamic -lgtest -L/usr/lib -Bdynamic -lgtest_main -Bdynamic -lpthread -fexceptions -lstdc++}
[INFO] Starting link {4.8.3 -L/usr/lib -Bdynamic -lgtest -L/usr/lib -Bdynamic -lgtest_main -Bdynamic -lpthread -fexceptions -lstdc++}
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
[ERROR] /usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
[ERROR] /home/sshakya/MavenC/Recent_Backup/COE/testlibrary/target/test-nar/obj/amd64-Linux-gpp/dummyTest.o: In function `__static_initialization_and_destruction_0(int, int)':
[ERROR] dummyTest.cpp:(.text+0x1f2): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
[ERROR] collect2: error: ld returned 1 exit status
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
The dummyTest.cpp, pom file and the project structure I am using is as follows :-
//
// File: dummyTest.cpp
//
#include "gtest/gtest.h"
TEST(dummyTest, AlwaysTrueTest) {
EXPECT_EQ(1, 1);
}
//
// File: pom.xml
//
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.coe</groupId>
<artifactId>testlibrary</artifactId>
<packaging>nar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<skipTests>false</skipTests>
<skipDeploy>false</skipDeploy>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<layout>NarLayout20</layout>
<libraries>
<library>
<type>executable</type>
<run>true</run>
</library>
</libraries>
<linker>
<name>g++</name>
<sysLibs>
<sysLib>
<name>pthread</name>
</sysLib>
</sysLibs>
<libs>
<lib>
<name>gtest</name>
<type>shared</type>
<directory>/usr/lib/</directory>
</lib>
<lib>
<name>gtest_main</name>
<type>shared</type>
<directory>/usr/lib/</directory>
</lib>
</libs>
</linker>
<tests>
<test>
<name>dummyTest</name>
<link>shared</link>
</test>
</tests>
</configuration>
</plugin>
</plugins>
</build>
It seems that I am doing it the right way reading from other blog posts and stackoverflow Q&A, but I could not figure out what is causing this problem. Any help or any hint towards the right direction would be highly appreciated. Thanks

Please check for contradicting versions of gtest in the search paths: Is the same gtest.h included during compilation as used for the library libgtest{,_main} you link to?