I am trying to run some simple gtest tests on an AIX machine:
#include <gtest/gtest.h>
int add(int a, int b) {
return a + b;
}
// Test case to check addition function
TEST(AdditionTest, PositiveNumbers) {
EXPECT_EQ(add(2, 3), 5);
EXPECT_EQ(add(-2, 3), 1);
EXPECT_EQ(add(-2, -3), -5);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
$path looks like:
/usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin /usr/java5/jre/bin /usr/java5/bin /usr/local/bin /mei_commands /wcsbin/com /wcsbin /opt/freeware/bin /usr/local/bin /bin /usr/bin /etc /usr/etc /rgti/test/bin /rgti/test/com /opt/freeware/include/gtest/ /opt/freeware/include
swarnagowri.bs > which cc
/usr/bin/cc
======================================
swarnagowri.bs > uname -a
AIX <server_name> 2 7 00C995884C00
Here is the command we are running to get it compiled:
cc hello_world.cpp /usr/lib/libC.a /opt/freeware/lib/libgtest.a /opt/freeware/lib/libgtestmain.a
But I keep getting:
"hello_world.cpp", line 2.10: 1540-0836 (S) The #include file <gtest/gtest.h> is not found.
Running with -I/opt/freeware/include added in the compilation command gives:
lingaraj.gondakar > cc hello_world.cpp /usr/lib/libC.a -I/opt/freeware/include
"/opt/IBM/xlC/16.1.0/include/tuple", line 68.5: 1540-0859 (S) #error directive: To use the tuple library, macro __IBMCPP_TR1__ must be defined
by user to non zero integer value..
"/opt/IBM/xlC/16.1.0/include/type_traits", line 315.5: 1540-0859 (S) #error directive: To use the type traits library, macro __IBMCPP_TR1__ must be defined
by user to non zero integer value..
"/opt/freeware/include/gtest/gtest-matchers.h", line 42.10: 1540-0836 (S) The #include file <atomic> is not found.
"/opt/freeware/include/gtest/internal/gtest-port.h", line 279.2: 1540-0859 (S) #error directive: C++ versions less than C++14 are not supported..
lingaraj @ wcsdev:/home/mouser.lan/lingaraj.gondakar/Code/wcs/code
lingaraj.gondakar >
Could you please help - thanks!
-I/opt/freeware/include
into your compile command.#define __IBMCPP_TR1__ 1
at the top of your code. Not sure about the other errors. They look pretty self-explanatory. It used to be that ittoolbox.com had more AIX people. Also the IBM support forums had (have) knowledgeable people. Good luck.