c++ - Failed to create first library. `undefined reference to `main` -


I am trying to create my first Linux based static library. I am following the instructions from this site here.

This code is

  #ifndef _ADDNUMBERS_H #define _ADDNUMBERS_H class AddNumbers {Private: int _a; Int _b; Public: AddNumbers (); ~ AddNumbers (); Zero set A (int a); Zero set B (int b); Int getA () console; Int getB () const; Int getSum () console; }; // AddNumbers #endif // _ADDNUMBERS_H ~ / Workspace / C ++ / AddNumbers / src / AddNumbers.cpp # Include "AddNumbers.h" AddNumbers :: AddNumbers (): _a (0), _b (0) {} AddNumbers :: ~ AddNumbers () {} zero addNumbers :: setA (int a) {_a = a; } Zero AddNumbers :: setB (int b) {_b = b; } Int AddNumbers :: getA () const {return _a; } Int AddNumbers :: getB () const {return _b; } Int AddNumbers :: getSum () const {return _a + _b; }  

This is the makefill I am using. Header and CPP files are next to each other

  cc = G ++ ifeq ($ (DEBUG), yes) CSFALGS = -VAL-LDFALGS = -Vagal-G and CASFALGS = -Lal LDFALGS = -Wall endif AR = ARFLAGS = rcs INC = AddNumbers.h SRC = AddNumbers.cpp OBJ = AddNumbers.o OUT = libAddNumbers.a contains I = .i #. / $ (INCPATH) Default: $ (out) $ (out)): $ (obz) $ (AR) $ (ARFLAGS) $ @ $ (oBJ) # means the target name is% .o:% .cpp $ (INC) $ (CC) $ (CXXFLAGS) $ (includes) -a $ & lt; -O $ @ .PHONY: Clearly Clear: RM-F *. O clean: Clean RM-F $ (out)  

This is my output

  admin @ localhost build Lib $ G ++ -Wall-I - C AddNumbers.cpp -o AddNumbers.o /usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../ ./lib64/crt1.o: in function `_start ': (.text + 0x20): Undefined context for` main' collection 2: Error: ld 1 exit status has created: *** [AddNumbers.o] Error 1 admin @loghost lib $  

How can I fix this problem?

I believe your argument is less -i Code> -c is swallowing the argument, so GCC does not see it and does not use the compile-only mode. / P>

Either give a value to your -i argument or get rid of it and see if it works.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -