Page 1 of 1

iostream problem...

Posted: Thu Jul 29, 2010 3:53 pm
by cgillopez
hello,

i wanna compile a program but i get some errors and i dont know what do i have to do. I hope you can give me a solution. Im using Windows, codelite v2.6.0.4189

gcc -c "C:/Program Files/CodeLite/h264_C++/main.c" -g -o ./Debug/main.o "-I." "-I."
C:/Program Files/CodeLite/h264_C++/main.c:4:20: error: iostream: No such file or directory
C:/Program Files/CodeLite/h264_C++/main.c:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
C:/Program Files/CodeLite/h264_C++/main.c:14: error: expected ';', ',' or ')' before '&' token
C:/Program Files/CodeLite/h264_C++/main.c:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'aGlobalUsername'
C:/Program Files/CodeLite/h264_C++/main.c:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'aGlobalPassword'
C:/Program Files/CodeLite/h264_C++/main.c:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'aGlobalRunning'


C:/Program Files/CodeLite/h264_C++/main.c:87: error: 'string' undeclared (first use in this function)

when my code is...

#include <stdio.h>
#include <getopt.h>
#include <signal.h>
#include <iostream>

using namespace std;



static void run(const string& theServer, unsigned int thePort,
const string& theURI, RTSPSession::ConnectionMode theMode,
bool theMulticastFlag, unsigned int theMediaMode,
const string& theOutputFile, const string& theSDPFile);
static void usage(void);
static void signal_handler(int signum);

/****************** GLOBAL VARIABLE DECLARATION SECTION *********************/

int aGlobalVerboseFlag = 0;
int aGlobalStatisticsFlag = 0;
string aGlobalUsername = "root";
string aGlobalPassword = "pass";
int aGlobalDelay = 0;
bool aGlobalRunning = true;

int main(int argc, char **argv)
string urui;
{...}

Thanks in advance for your help.

Re: iostream problem...

Posted: Thu Jul 29, 2010 5:53 pm
by eranif
You are compiling C++ code with C compiler (the file is named main.c, and the compiler used is gcc while it should be g++)
In addition, dont forget to include '#include <string>' (without .h)
Eran

Re: iostream problem...

Posted: Fri Jul 30, 2010 10:30 am
by cgillopez
Thank you eranif, now its working.