LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Puppy (http://www.linuxquestions.org/questions/puppy-71/)
-   -   Compiling and running programs in Lucid Puppy 2.5.2 (http://www.linuxquestions.org/questions/puppy-71/compiling-and-running-programs-in-lucid-puppy-2-5-2-a-928846/)

Atharv Patil 02-11-2012 02:25 PM

Compiling and running programs in Lucid Puppy 2.5.2
 
I have downloaded devx and configured it with puppy and it works well. But i cannot compile and run c++ programs. I used the g++, but it always shows sum error even if everything is correct. I think that the libraries for c++ are old and so i am downloading latest release of gcc. Will it help me compiling and running c++ programs? If no, then how do i do it? And how do i add other programming languages in my puppy, like latest ver of python, ruby and some other languages?

TB0ne 02-12-2012 10:51 PM

Quote:

Originally Posted by Atharv Patil (Post 4599887)
I have downloaded devx and configured it with puppy and it works well. But i cannot compile and run c++ programs. I used the g++, but it always shows sum error even if everything is correct.

Spell out your words. And if everything is correct, you won't have errors.
Quote:

I think that the libraries for c++ are old and so i am downloading latest release of gcc. Will it help me compiling and running c++ programs? If no, then how do i do it? And how do i add other programming languages in my puppy, like latest ver of python, ruby and some other languages?
No idea, since you don't tell us what error(s) you're getting. Also, you say you're using "Lucid Puppy 2.5.2"?? That's VERY old, and quite likely unsupported...the latest version is 5.2.8. The best way to get everything correct, is to do a fresh install of a current version of Linux. Python, ruby, and 'other languages' will be automatically installed/updated, as will g++ and development libraries.

If you mean you're using 5.2.5, have you looked at LucidPuppyUpdate?? You can update things online.
http://puppylinux.org/wikka/LucidPuppyUpdate

Atharv Patil 02-14-2012 12:47 AM

Sorry, i am actually using puppy 5.2.5. Given below a program i tried to compile using g++

#include<iostream.h>
void main()
{
cout<<"hello";
}

there might be errors in the above program but the one i tried to compile was 100% correct. When i compiled it, it gave errors. 1 related to the main(), 1 related to cout. I cannot tell what were the actual errors because i am posting this reply via cell phone. What can be the problem?

jhwilliams 02-14-2012 01:05 AM

Well, without the output it's hard to say. But you're doing at least three things which are weird.

1. You should say iostream, not iostream.h.
2. The main signature usually returns int.
3. You need to specify a scope for cout.

Code:

#include <iostream>

int main(void) {
    std::cout << "Hello, world.\n";
    return 0;
}


TB0ne 02-14-2012 11:03 AM

Quote:

Originally Posted by Atharv Patil (Post 4601770)
Sorry, i am actually using puppy 5.2.5. Given below a program i tried to compile using g++
Code:

#include<iostream.h>
void main()
{
cout<<"hello";
}

there might be errors in the above program but the one i tried to compile was 100% correct. When i compiled it, it gave errors. 1 related to the main(), 1 related to cout. I cannot tell what were the actual errors because i am posting this reply via cell phone. What can be the problem?

Well again, if the code was 100% correct, you wouldn't get errors. Errors are a good indication that there is a problem.....have you tried to compile/run any OTHER C++ programs, aside from the one you posted/wrote??

Atharv Patil 02-15-2012 02:47 AM

I did not use the conventions you posted earlier, i used the traditional iostream.h and void main(). I think that must be the problem. Is it the Linux convention that main should return int and the header file should be iostream and not iostream.h?

WarTurkey 03-30-2012 10:15 AM

No, this is standard C++ conventions:

http://www.cplusplus.com/doc/tutoria...ram_structure/
Code:

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

http://en.wikipedia.org/wiki/C%2B%2B
Code:

#include <iostream>
 
int main()
{
  std::cout << "Hello, world!\n";
}

http://www.cprogramming.com/tutorial/lesson1.html
Code:

#include <iostream>
 
using namespace std;
 
int main()
{
  cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
  cin.get();
}



All times are GMT -5. The time now is 08:25 PM.