473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

g++ and make

This might be a little bit off group but I wanted to learn to work with
make in linux so I write this makefile

main: main.cpp ./EscribeHolaMundo.cpp ./EscribeHolaMundo.H
g++ -I. main.cpp ./EscribeHolaMundo.cpp -o main

with

EscribeHolaMundo.cpp

#include <iostream>

void EscribeHolaMundo() {
cout << "Hola Mundo";
}

and

main.cpp

#include <EscribeHolaMundo.H>

int main(int argc, char *argv[]) {
EscribeHolaMundo();
}

now, with this, make doesn't recognize cout

../EscribeHolaMundo.cpp:4: error: `cout' undeclared (first use this
function)

but if I use the old c sintaxis with <iostream.h>, then g++ produces
its warning about the deprecated headers but works. Can somebody tell
me why it doesn't work with <iostream>?

Daniel

Sep 25 '06 #1
2 1555
Daniel wrote:
This might be a little bit off group but I wanted to learn to work with
make in linux so I write this makefile

main: main.cpp ./EscribeHolaMundo.cpp ./EscribeHolaMundo.H
g++ -I. main.cpp ./EscribeHolaMundo.cpp -o main

with

EscribeHolaMundo.cpp

#include <iostream>

void EscribeHolaMundo() {
cout << "Hola Mundo";
}

and

main.cpp

#include <EscribeHolaMundo.H>

int main(int argc, char *argv[]) {
EscribeHolaMundo();
}

now, with this, make doesn't recognize cout

./EscribeHolaMundo.cpp:4: error: `cout' undeclared (first use this
function)

but if I use the old c sintaxis with <iostream.h>, then g++ produces
its warning about the deprecated headers but works. Can somebody tell
me why it doesn't work with <iostream>?

Daniel
This has nothing to do with makefiles (neither does this
group). You forgot to write

using namespace std;

after your #include<iostream>

The issue is that the new header files (ones without the .h)
declare symbols in the std namespace, whereas the old ones
(with the .h), which you should avoid, declare the symbols
globally.

HTH,
- J.
Sep 25 '06 #2
>
This has nothing to do with makefiles (neither does this
group). You forgot to write

using namespace std;

after your #include<iostream>

The issue is that the new header files (ones without the .h)
declare symbols in the std namespace, whereas the old ones
(with the .h), which you should avoid, declare the symbols
globally.

HTH,
- J.
Of course, very stupid of me, thanks

Daniel

Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Blaha | last post by:
Hi, I'm runnig Linux/Mandrake9.0-Dolphin and try to update Apache 2.0.46 and PHP 4.3.2. Apache is OK bu with PHP I've problem. I unpacked distribution, run ../configure > configure.vysl, make...
0
by: pptran | last post by:
Hi, I am pretty new to building and installing Perl. Can someone help explain the severity of the following Perl 5.8.4 build error message? ==================================================...
2
by: Glenn | last post by:
Hi, I'm using cygwin and am trying to install DBI-mSQL and am getting errors on make .. any idea how to fix this (TIA): cpan> install DBD::mSQL Running install for module DBD::mSQL Running...
9
by: Joel Rodrigues | last post by:
Hi, I get the following error when I run make on Mac OS X v 10.1.5 Any ideas ? ---------------------------------------------------------- ar: illegal option -- s usage: ar -d archive file ......
8
by: Seeker | last post by:
Hello, In using Solaris Pro Compiler to compile Pro*C code. I am getting this error: make: Fatal error in reader: parser_proc_online.mk, line 26: Badly formed macro assignment Based on other...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
10
by: Johs | last post by:
I have a source file called project.c. In the same folder I have a Makefile containing: CC=gcc CFLAGS=-g project: project.c $(CC) $(CFLAGS) project.c -o project
4
by: jalqadir | last post by:
Now that I am trying to install Debian from a CD, I found that the network card was not supported, I read that some dude had found a driver for the NIC in a MSI-M662 laptot, I myself don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.