c++ - g++ link problems: In function `_start': (.text+0x20): undefined reference to `main' -


i getting undefined reference main error - though have defined main, , (afaict), have linked correctly. here code , commands used:

// ################################################ //proj1.h #ifndef  __scratch_proj1_h #define  __scratch_proj1_h  int addone(int i);  #endif /*__scratch_proj1_h */  // ################################################  //proj1.cpp #include "proj1.h"  int addone(int i){     return i+1; }   // ################################################ //proj1_unittest.cpp  #include "proj1.h" #include "gtest/gtest.h"  // test function test(addonetest, positive) {     expect_eq(1,addone(0));                 expect_eq(2,addone(1));                 expect_eq(40320, addone(40319));    }  test(addonetest, negative) {     expect_false(addonetest(-1));       }   gtest_api_ int main(int argc, char **argv) {   testing::initgoogletest(&argc, argv);   return run_all_tests(); } 

here console output:

$ g++ -isystem -pthread -c ${source_dir}/proj1.c -o ${source_dir}/proj1.o $ g++ -o ${source_dir}/mytest ${source_dir}/*.o -l${gtest_dir} libgtest.a  /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: in function `_start': (.text+0x20): undefined reference `main' collect2: ld returned 1 exit status 

why main() function not been found linker?

as far can see not compiling file proj1_unittest.cpp (as code comment has it) / proj1_unittest.c (as console output implies).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -