LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2003, 06:48 AM   #1
mentrial
LQ Newbie
 
Registered: Feb 2003
Posts: 2

Rep: Reputation: 0
about makefile and stuff


i'm a real both with linux and c++ (or any other)

i was trying to make this

#include <iostream.h>

int main()
{
cout << "¡Hola mundo!\n";
return 0;
}

yes, i know it's simple but i can't even do that

i wrote the code in a new file in emacs, and when i try to compile it it say's that i needed a makefile
the book from where i'm learning doesnt say anything about a makefile

if anyone could help my with this i'll by gratefull
 
Old 02-10-2003, 06:51 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well that in itself doesn't need a makefile, you'd use one when distributing an application but just that you'd compile using "gcc code.c -o code" or such like. nothing else would be needed. btw you're using deprecated code now. cout is no longer resident in the default name space. either add a line saying "using namespace std;" before using it, or change "cout" to "std::cout"
 
Old 02-10-2003, 07:00 AM   #3
mentrial
LQ Newbie
 
Registered: Feb 2003
Posts: 2

Original Poster
Rep: Reputation: 0
ummm thanks, but what's "gcc code.c -o code" keeps telling me that it doesn't found a makefile.
cant i use cout? what's that stuff?
 
Old 02-10-2003, 07:12 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
sorry.. can you say that again.... you type "gcc....." in a terminal if that's what you mean.

you can set emacs up to do it, but i don't use emacs so can't help you with that. you could write a makefile for it if you wanted to ... just have a look on google for some beginners guides, you'd only need a line or two.
 
Old 02-10-2003, 10:03 AM   #5
evil_lafta
LQ Newbie
 
Registered: Dec 2002
Location: nigeria
Distribution: slackware 8.1
Posts: 12

Rep: Reputation: 0
or u can use "g++ code.c -o code" and run the executable by typing "./code"
 
Old 02-10-2003, 03:02 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
If you invoke compile from emacs you'll have to modify the
mini-buffer to say
Code:
gcc code.c -o code
rather than make (or make -k in your case) :)

Cheers,
Tink
 
Old 02-10-2003, 05:48 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Alternatively, create a file named Makefile
and do something like that :}

Makefile:
Code:
#Make for code snippet
BASEDIR=${PWD}
CCC=g++
CC=gcc
#directories for include files
INC=-I/usr/lib/qt/include -I/usr/local/include/stlport 
#required libraries
LIBS=-L/usr/lib/qt/lib -lqt-mt -L/usr/local/lib -lstlport_gcc
CFLAGS=-g -DLINUX -DLINUX_GPP -Woverloaded-virtual  ${INC} 

code: code.o
	${CCC} ${CFLAGS} ${LIBS} code.cc  -o code
Edit INC and LIBS (or actually everything) to your hearts content ;)

Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to modify makefile.in or makefile.am QiangWan Linux - Newbie 1 05-17-2005 11:07 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
When installing new stuff in suse 9.1, do you uninstall old stuff first? randon SUSE / openSUSE 1 12-25-2004 04:37 PM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM
what is @ in makefile? beautifulmind Programming 5 07-17-2002 09:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration