Makefile ? how to create it ?

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 6532 Views - Last Post: 09 March 2011 - 07:38 AM Rate Topic: -----

#1 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Makefile ? how to create it ?

Posted 08 March 2011 - 02:17 AM

After working full for two days to finish my homework , the Makefile seems very annoying .
Can someone please explain how to create it ?

I'm working on Eclipse under Linux (using VMWARE on WINDOWS 7) .

I found on the web a little example :


sum: main.o sum.o
	gcc –o sum main.o sum.o

main.o: main.c sum.h
	gcc –c main.c 

sum.o: sum.c sum.h
	gcc –c sum.c 



but I don't know what to do about it . I'd appreciate any help

Regards,Ron

This post has been edited by NickDMax: 08 March 2011 - 08:50 AM
Reason for edit:: added code tags: [code]...paste your code here...[/code]


Is This A Good Question/Topic? 1
  • +

Replies To: Makefile ? how to create it ?

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 04:48 AM

just create a file called "makefile" with no file extension, then put your make script into the file. To build the application, just navigate to the directory containing the makefile and type "make ", then the name of the rule which you want to use when building the application. For example, in your case, you would type "make sum".

Edit: Sorry, just realised that you said you were working on Linux, but the steps remain the same, I'm sure.

in your case, it'll be something like

$ touch makefile   
$ cd path/to/your/makefile
$ make sum

This post has been edited by Aphex19: 08 March 2011 - 05:00 AM

Was This Post Helpful? 2
  • +
  • -

#3 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 05:27 AM

Have a read of these:

http://www.opussoftw...TutMakefile.htm

http://mrbook.org/tutorials/make/

http://www.eng.hawaii.edu/Tutor/Make/

http://www.cs.umd.ed...l/makefile.html

If you have any specific questions after that please don't hesitate to ask.
Was This Post Helpful? 0
  • +
  • -

#4 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 10:37 AM

Well make files ARE irritating and that is a big reason why there are so many competing build tools out there. So if you are doing something non-trivial you may wish to look at using another build tool:

Boost.Build -
ANT -
Scons -

a big list of build tools

So if what you are doing is non-trivial especially if it requires tools other then the compiler/linker/assembler then you may wish to look into some of the other build tools. While you CAN do things like integrate with source control CVS/SVN/Git - or ensuring libraries are updated via ftp etc. with make it generally begins to get harry.

The structure of a make file is generally pretty easy, I generally use 3 features:

#1 define MACROS (I usually define CC (compiler), CFLAGS (compiler flags), LD (linker - sometimes I call this LINK since I am on windows), AS, OBJS (list object files)
#3 Targets - tell how to create a particular file
#2 Dependency rules -- lists other files and targets needed to create the current target.

So here is something I might have (remember I am on windows):
#macros for some libraries are are used
BOOST_INCLUDE = "C:\CProjects\boost_1_39_0"
TTMATH_INCLUDE = "C:\CProjects\TTMath\ttmath-0.9.2"

#macros for using MinGW for the build
MINGW_CC = "C:\MinGW5.1.6\bin\g++.exe"
MINGW_INCLUDE = "C:\MinGW5.1.6\include"
MINGW_CFLAGS =  -O2 -I$(MINGW_INCLUDE) 
MINGW_CCOUT = -o

#macros for using VS2010 for the build
MS2010_32_CC = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe"
MS2010_32_LINK = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe"
MS2010_32_INCLUDE = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
MS2010_32_LIBS = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib"
MS2010_32_PSDK_LIBS = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"


MS2010_32_CFLAGS = /EHsc /fp:fast /c /I $(MS2010_32_INCLUDE)
MS2010_32_LLAGS = 
MS2010_32_LIB = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\lib.exe"
MS2010_32_CCOUT = /Fo

#macros needed for BorlandC
BORLAND_CC = "C:\Borland\BDS\4.0\Bin\bcc32.exe"
BORLAND_INCLUDE = 
BORLAND_CFLAGS = -O2 

#fill out the standard macros
CFLAGS = $(MS2010_32_CFLAGS)
CC = $(MS2010_32_CC)
LINK = $(MS2010_32_LINK)
LIB = $(MS2010_32_LIB)
OUT = $(MS2010_32_CCOUT)

OBJS = drawing.obj misc.obj mouse.obj palette.obj text.obj winbgi.obj winthread.obj file.obj dibutil.obj

#the final product
libbgi.lib: $(OBJS) winbgi.h winbgim.h graphics.h
	$(LIB) /OUT:libbgi.lib $(OBJS)

#the indi
drawing.obj : drawing.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) drawing.cxx $(OUT)drawing.obj

misc.obj : misc.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) misc.cxx $(OUT)misc.obj

mouse.obj : mouse.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) mouse.cxx $(OUT)mouse.obj

palette.obj : palette.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) palette.cxx $(OUT)palette.obj

text.obj : text.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) text.cxx $(OUT)text.obj

winbgi.obj : winbgi.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) winbgi.cxx $(OUT)winbgi.obj

winthread.obj : winthread.cxx winbgi.h winbgitypes.h
	$(CC) $(CFLAGS) winthread.cxx $(OUT)winthread.obj

dibutil.obj : dibutil.c dibutil.h dibapi.h
	$(CC) $(CFLAGS) /TP dibutil.c $(OUT)dibutil.obj

file.obj : file.c dibutil.h dibapi.h winbgitypes.h
	$(CC) $(CFLAGS) /TP file.c $(OUT)file.obj

circletest.obj : circletest.c graphics.h
    $(CC) $(CFLAGS) /TP /MT  /D "WIN32" circletest.c $(OUT)circletest.obj

circletest.exe : circletest.obj libbgi.lib
    $(LINK) circletest.obj libbgi.lib /OUT:circletest.exe /LIBPATH:$(MS2010_32_LIBS) /LIBPATH:$(MS2010_32_PSDK_LIBS) 



So this build (for libbgi I it looks like) uses a number of macros to kind-of abstract the build tools (although the last three targets are obviously compiler specific and that probably represents changes made for the last build I tried to do).

This is pretty standard kind of use. Any file that takes an operation to generate (like object files, executables, libraries etc.) becomes a target with the operation needed to preform the operation in the line below it.

Macros are used to simplify lines - more to the point they let you standardize lines so for example if you want to change your compiler you can just change CC rather than each target that uses the compiler, if you want to change a compiler flag you can do it in one place rather than 50 etc.

Macros can be built up, so for example if you need different compiler flags for different targets you can put all of the common flags in CFLAGS and then use that to make up ones for other sets of targets.

Each library you use should be defined in its own set of macros (for include/libs etc) so that you are not scanning a long list of directories looking to update the version of library etc.

Make can execute any tool you can execute from the command line, but it is not every good at taking feedback or interactive sessions (though the GNU make is quite sophisticated so don't rule anything out before researching it). My advice if you need to use things like CVS, or ftp, or run automatic test cases etc. use a better build system that is designed for that kind of thing. Make is designed to ensure that the most recent version of each dependency is used to construct each target - this is fantastic! but it is also rudimentary.
Was This Post Helpful? 3
  • +
  • -

#5 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 11:19 AM

Guys ,first of all thanks for the help ,really!

Second, this thing is making me crazy, even more crazy than running after the pointers of my d-list : )

Here is what I wrote within the "makefile" file , but Eclipse doesn't like it .

Ideas would be most appreciated

#file: makefile

a.out : main.o LinkedList.o Middle.o Student.o  
	g++ main.o LinkedList.o Middle.o Student.o  

main.o : main.cpp LinkedList.h LinkedList.cpp Middle.h Middle.cpp
	 g++ -c main.cpp

LinkedList.o :  LinkedList.cpp LinkedList.h
		g++ -c LinkedList.cpp 

Middle.o : Middle.cpp Middle.h Student.cpp Student.h LinkedList.h LinkedList.cpp
 	 g++ -c Middle.cpp 

Student.o : Student.cpp Student.h
   	  g++ -c Student.cpp 



Regards,Ron

This post has been edited by passer_by: 08 March 2011 - 11:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 12:30 PM

Quote

but Eclipse doesn't like it


Are we supposed to know what that means?
Was This Post Helpful? 0
  • +
  • -

#7 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 12:36 PM

#1 can you expand upon "but Eclipse doesn't like it ." -- please post any error you are getting as these can be helpful for us in troubleshooting your problem.

The one line that really concerns me is:
Middle.o : Middle.cpp Middle.h Student.cpp Student.h LinkedList.h LinkedList.cpp

Middle.o may depend upon Student.cpp and LinkLest.cpp but (as long as you are doing things right) only in that they are made into object files. So that whould probably be:

Middle.o : Student.o LinkedList.o Middle.cpp Middle.h Student.h LinkedList.h

That means that Student.o and LinkedList.o will be made before Middle.o

BUT since you don't actually use the .o files (because you are not linking here) you probably only need:

Middle.o : Middle.cpp Middle.h Student.h LinkedList.h
Was This Post Helpful? 0
  • +
  • -

#8 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 01:22 PM

View PostJackOfAllTrades, on 08 March 2011 - 12:30 PM, said:

Quote

but Eclipse doesn't like it


Are we supposed to know what that means?

It just showed me a X near the line before last(Student.o : Student.cpp Student.h) ,line 15 in the code above , and gave no more details .
Believe me if I've had more details ,I would have posted them here.

One thing that occurs to me , after building the project all over again , I looked at
the "DEBUG" folder and I saw there a "makefile" file .Could it be that Eclipse makes
the "makefile" for me ?

Thank you all for the help

This post has been edited by passer_by: 08 March 2011 - 01:24 PM

Was This Post Helpful? 0
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 02:03 PM

actually if you are using Eclipse correctly it does create a makefile for you. It can also use one you provide if/when your project becomes more complex but for simple projects (and yours seems pretty simple) Eclipse should be able to build the project without one (I *think* it makes one in the background) and should be able to generate one.
Was This Post Helpful? 0
  • +
  • -

#10 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 03:08 PM

Well, that's not particularly helpful of Eclipse, is it? I feel your pain...seeing similar stupid and unhelpful errors from the .NET app which is the bane of my existence...
Was This Post Helpful? 0
  • +
  • -

#11 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 06:54 PM

Guys, this Makefile thing just doesn't work.I've been trying for several hours to make this work
but nothing , and I even went through everything you posted here again and it still doesn't work.


Those are the files that I use , 7 files and no more :

main.cpp
LinkedList.cpp
LinkedList.h
Student.cpp
Student.h
Tafrit.cpp
Tafrit.h

Can you please help me figuring out how to build that little annoying file ? I must submit the files
within the next two hours.


Thanks
Ron
Was This Post Helpful? 0
  • +
  • -

#12 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 08:02 PM

OK , so now I think that I've made some progress , I've wrote a makefile with the help
of some manual I found and here it is :

CPP01_LinkedList:LinkedList.o main.o Student.o Tafrit.o
	gcc LinkedList.o main.o Student.o Tafrit.o -o CPP01_LinkedList
LinkedList.o: LinkedList.cpp LinkedList.h Student.h
	gcc -c LinkedList.cpp
main.o: main.cpp LinkedList.h Student.h Tafrit.h
	gcc -c main.cpp
Student.o: Student.cpp Student.h
	gcc -c Student.cpp
Tafrit.o: Tafrit.cpp Tafrit.h LinkedList.h Student.h
	gcc -c Tafrit.cpp


But after I do "make" in Terminal , I get this:
gcc -c LinkedList.cpp
gcc -c main.cpp
gcc -c Student.cpp
gcc -c Tafrit.cpp
gcc LinkedList.o main.o Student.o Tafrit.o -o CPP01_LinkedList
LinkedList.o: In function `LinkedList::setHead(Student*)':
LinkedList.cpp:(.text+0x36): undefined reference to `operator new(unsigned int)'
LinkedList.o: In function `LinkedList::RemoveFromList(Student*)':
LinkedList.cpp:(.text+0x2d6): undefined reference to `operator delete(void*)'
LinkedList.cpp:(.text+0x346): undefined reference to `operator delete(void*)'
LinkedList.cpp:(.text+0x39c): undefined reference to `operator delete(void*)'
LinkedList.cpp:(.text+0x3e3): undefined reference to `operator delete(void*)'
LinkedList.cpp:(.text+0x448): undefined reference to `operator delete(void*)'
LinkedList.o: In function `LinkedList::AddStudentByIndex(Student*, int)':
LinkedList.cpp:(.text+0x594): undefined reference to `std::cout'
LinkedList.cpp:(.text+0x599): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0x5a1): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
LinkedList.cpp:(.text+0x5a9): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
LinkedList.cpp:(.text+0x5f3): undefined reference to `std::cout'
LinkedList.cpp:(.text+0x5f8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0x600): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
LinkedList.cpp:(.text+0x608): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
LinkedList.cpp:(.text+0x628): undefined reference to `operator new(unsigned int)'
LinkedList.cpp:(.text+0x748): undefined reference to `operator new(unsigned int)'
LinkedList.cpp:(.text+0x7ee): undefined reference to `operator new(unsigned int)'
LinkedList.cpp:(.text+0x87f): undefined reference to `operator new(unsigned int)'
LinkedList.cpp:(.text+0x9cb): undefined reference to `operator new(unsigned int)'
LinkedList.o: In function `LinkedList::PrintList()':
LinkedList.cpp:(.text+0xa90): undefined reference to `std::cout'
LinkedList.cpp:(.text+0xa95): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xa9d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
LinkedList.cpp:(.text+0xaa5): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
LinkedList.cpp:(.text+0xae3): undefined reference to `std::cout'
LinkedList.cpp:(.text+0xae8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xaf4): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
LinkedList.cpp:(.text+0xb04): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xb0c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
LinkedList.cpp:(.text+0xb14): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
LinkedList.cpp:(.text+0xb39): undefined reference to `std::cout'
LinkedList.cpp:(.text+0xb3e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xb4a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
LinkedList.cpp:(.text+0xb75): undefined reference to `std::cout'
LinkedList.cpp:(.text+0xb7a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xb86): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
LinkedList.cpp:(.text+0xba9): undefined reference to `std::cout'
LinkedList.cpp:(.text+0xbae): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
LinkedList.cpp:(.text+0xbb6): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
LinkedList.cpp:(.text+0xbbe): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
LinkedList.o: In function `LinkedList::AddNewStudentToDLL(Student*, Student*)':
LinkedList.cpp:(.text+0xcc8): undefined reference to `operator new(unsigned int)'
LinkedList.o: In function `__static_initialization_and_destruction_0(int, int)':
LinkedList.cpp:(.text+0xef8): undefined reference to `std::ios_base::Init::Init()'
LinkedList.cpp:(.text+0xefd): undefined reference to `std::ios_base::Init::~Init()'
LinkedList.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
main.o: In function `main':
main.cpp:(.text+0x14): undefined reference to `operator new(unsigned int)'
main.cpp:(.text+0x2e): undefined reference to `operator delete(void*)'
main.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x7a): undefined reference to `std::ios_base::Init::Init()'
main.cpp:(.text+0x7f): undefined reference to `std::ios_base::Init::~Init()'
main.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
main.o:(.eh_frame+0x6e): undefined reference to `__gxx_personality_v0'
Student.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
Tafrit.o: In function `Tafrit::AddNewStudent(int)':
Tafrit.cpp:(.text+0x39): undefined reference to `operator new(unsigned int)'
Tafrit.cpp:(.text+0x53): undefined reference to `operator delete(void*)'
Tafrit.o: In function `Tafrit::CreateNewList()':
Tafrit.cpp:(.text+0x8b): undefined reference to `operator new(unsigned int)'
Tafrit.cpp:(.text+0xa5): undefined reference to `operator delete(void*)'
Tafrit.o: In function `Tafrit::start()':
Tafrit.cpp:(.text+0xd6): undefined reference to `std::cout'
Tafrit.cpp:(.text+0xdb): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
Tafrit.cpp:(.text+0xe3): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
Tafrit.cpp:(.text+0xeb): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
Tafrit.cpp:(.text+0xf9): undefined reference to `std::cin'
Tafrit.cpp:(.text+0xfe): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x13d): undefined reference to `operator delete(void*)'
Tafrit.cpp:(.text+0x171): undefined reference to `std::cin'
Tafrit.cpp:(.text+0x176): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x1ba): undefined reference to `std::cin'
Tafrit.cpp:(.text+0x1bf): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x203): undefined reference to `std::cin'
Tafrit.cpp:(.text+0x208): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x234): undefined reference to `std::cout'
Tafrit.cpp:(.text+0x239): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
Tafrit.cpp:(.text+0x241): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
Tafrit.cpp:(.text+0x249): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
Tafrit.cpp:(.text+0x25d): undefined reference to `std::cout'
Tafrit.cpp:(.text+0x262): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
Tafrit.cpp:(.text+0x26a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
Tafrit.cpp:(.text+0x272): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
Tafrit.cpp:(.text+0x28a): undefined reference to `std::cin'
Tafrit.cpp:(.text+0x28f): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x29e): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x2f9): undefined reference to `std::cin'
Tafrit.cpp:(.text+0x2fe): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.cpp:(.text+0x30d): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
Tafrit.o: In function `__static_initialization_and_destruction_0(int, int)':
Tafrit.cpp:(.text+0x38a): undefined reference to `std::ios_base::Init::Init()'
Tafrit.cpp:(.text+0x38f): undefined reference to `std::ios_base::Init::~Init()'
Tafrit.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
Tafrit.o:(.eh_frame+0x9f): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [CPP01_LinkedList] Error 1


The thing is that the Project compiles perfectly well in Eclipse , not a single error or warning.
But here everything is WRONG.

I'd appreciate your help , Ron
Was This Post Helpful? 0
  • +
  • -

#13 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 09:22 PM

g++, not gcc. gcc is for C. g++ is for C++.
Was This Post Helpful? 0
  • +
  • -

#14 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 09:29 PM

View PostOler1s, on 08 March 2011 - 09:22 PM, said:

g++, not gcc. gcc is for C. g++ is for C++.

Thank you so much!!
Works like a charm , I'll check again and get back to you guys.
Was This Post Helpful? 0
  • +
  • -

#15 passer_by  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 234
  • Joined: 06-March 11

Re: Makefile ? how to create it ?

Posted 08 March 2011 - 09:50 PM

Something that not so clear to me : when I check the size of the .o files (OBJECTS) I see
a big difference between the size of the object files Eclipse has created , and the size
the "make" has created.

Is it okay ?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2