GNU GCC compilor error “multiple definition of main”

前端 未结 3 1125
天涯浪人
天涯浪人 2021-01-24 00:38

I am new to ubuntu, now I need to develop my assignment in C++. I am using codeblocks IDE to write c++ programs. Whenever I compile something in it, it gives these errors:

3条回答
  •  萌比男神i
    2021-01-24 01:12

    The program compiles fine with (yourcode.cc contains your sourcecode):

    $ CXXFLAGS="-Wall -Werror -Wpedantic" make yourcode
    
    stack.cc: In member function ‘int List::get()’:
    stack.cc:76:1: error: control reaches end of non-void function [-Wreturn-type]
     }
    

    and invoking ./yourcode outputs:

     List size = 5
    
     Element 1 2
     Element 2 6
     Element 3 8
     Element 4 7
     Element 5 1
    

    Obviously your IDE is going to add some flags to the linker. Please show us your compile flags/setting. See the compile log or run the make command executing more verbose.

    May have a look at. Code::blocks verbose build

提交回复
热议问题