November 2008

You are currently browsing the monthly archive for November 2008.

Compile C C++ in linux

i have studied c++ for my exam today and i will explain how can you compile c/c++ in linux also there were some error that i want mention.

1.install eclipse (not necessary for compiling)
probably you can find it from your package manager if there isn’t
use this link: http://www.eclipse.org
for pardus open pisi search for eclipse and install it ( 3.3)

2. install CDT plugin for eclipse
open eclipse help -> software updates -> avilable softwares -> add site
for eclipse 3.4 add this:

http://download.eclipse.org/tools/cdt/releases/ganymede

for eclipse 3.3 add this:

http://download.eclipse.org/tools/cdt/releases/europa

check it and click install

you have eclipse CDT to write your c and c++ codes
now you need gcc to compile it

3. install gcc
find gcc from your package manager.
for pardus write this to console
sudo pisi it gcc

4. first simple
i opened a new c++ project from eclipse, created new source file, writed my code and saved. when i am trying to make file,
I received this message “(Exec error:Cannot run make)” .

(solution: install make from your package manager.For pardus write this sudo pisi it make.)

after that i tried it on console with giving this command

(for c++ codes)

g++ example.cpp

(for c codes)

gcc example.c

however, i received “iostream.h: No such file or directory gcc”
solution: delete .h just write <iostream> also write g++ for *.cpp files

after i installed make, i was able to compile it from console and eclipse.

if you want to see your code’s output:

g++ example.cpp

it makes a compiled file named example in your folder

to run it just write

./example

i hope , help you.

Related posts

Tags: , , , , ,

Open console and write

  • pisi update-repo
  • sudo pisi it apache mysql-server mod_php
  • sudo mysql_install_db
  • sudo service mysql-server on
  • sudo service apache on

After you should restart your comptuter

Test

<?php

echo “Hello World”;

?>

save this as test.php and copy /var/www/localhost/htdocs/

write firefox http://localhost/test.php

if you do eveything correct,  you will see hello world on page

Related posts

Tags: , ,

Difference between include and require: if you use include and there is not page that you include , you get a warning. Otherwise if you use require instead of include you will get a fatal error.

for more information

http://tr2.php.net/include/

http://tr2.php.net/require

Related posts

Tags: , ,