Comment executer un pgm sous fedora

Fermé
toto09 - 16 mars 2010 à 19:20
mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 - 25 mars 2010 à 15:03
Bonjour,
j'ai un pb avec l'execution d'un pgm ecrit en c++ qui utilise des includes .quand je tape la commande de compilation sous terminal il m'affiche fichier ou repertoire non trouver (include .h).................................aides moi svp

7 réponses

mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 7 749
17 mars 2010 à 15:22
Tout dépend des headers que tu cherches à inclure et du programme que tu compiles. A priori la compilation se fait par le biais d'un makefile qui appelle g++ et lui passe des options. Parmi les options qui t'intéressent, -I (et -isystem) permet de préciser où trouver des headers quand ils ne sont pas dans un répertoire standard (/usr/include) ou dans le répertoire du fichier en train d'être compilé.

Pour plus de précisions il nous faudrait une archive du code source que tu cherches à compiler.

Bonne chance
0
salut mamiemando.mercie pour ta reponse et voila le code

#include <LEDA/graph_alg.h>
#include <LEDA/dimacs.h>
#include <LEDA/node_list.h>
#include <LEDA/b_queue.h>
#include <LEDA/stream.h>

#if defined(LEDA_STD_IO_HEADERS)
using namespace std;
#endif


int main(int argc, char** argv)
{
int node_slots = 2;
int edge_slots = 1;

GRAPH<int,int> G(node_slots,edge_slots);

edge_array<int>& cap = G.edge_data();

edge_array<int> flow;
flow.use_edge_data(G,0);

node s,t;

cout << endl;

if (argc < 2)
{ cout << "reading DIMACS maxflow problem from std input ... ";
cout << flush;
Read_Dimacs_Maxflow(cin,G,cap,s,t);
cout << endl;
}
else
{ cout << "reading DIMACS maxflow problem from " << argv[1] << " ... ";
cout <<flush;
ifstream in(argv[1]);
Read_Dimacs_Maxflow(in,G,cap,s,t);
}

cout << endl;

int pushes,relabels,updates,gap_nodes,inspects;

int n = G.number_of_nodes();
int m = G.number_of_edges();

cout << string("%6d nodes",n) << endl;
cout << string("%6d edges",m) << endl;
cout << endl;

cout << "MAX_FLOW " << flush;
float T = used_time();

int f = MAX_FLOW(G,s,t,cap,flow,pushes,inspects,relabels,updates,gap_nodes) ;

cout << endl;
cout << " ";
cout << string("time: %6.2f sec f = %d",used_time(T),f) << endl;
cout << endl;
cout << " ";
cout << string("pushes:%d relabels:%d updates:%d insp:%d gap nodes:%d",
pushes, relabels, updates, inspects, gap_nodes) << endl;
cout << endl;

CHECK_MAX_FLOW(G,s,t,cap,flow);

return 0;
}
0
mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 7 749
22 mars 2010 à 11:33
Bon et bien là, il faut que tu précises à la compilation ou trouver le répertoire LEDA qui contient les headers graph_alg.h etc...

Supposons que par exemple le chemin soit /aaa/bbb/ccc/LEDA/graph_alg.h :

g++ -W -Wall -I/aaa/bbb/ccc fichier.c -o executable


Bonne chance
0
moi je veut simuler un protocol sous fedora et j'utilise le simulateure LEDA ET VOILA LES ETAPES d'installation .je le fait mais quand je compile un exemple il m'affiche un msg d'erreure.aides moi svp
LEDA

UNIX OBJECT CODE INSTALLATION


1. Preparations
---------------

Unpacking the LEDA distribution file (LEDA-<ver>-<sys>-<cc>.tgz) will
create the LEDA root directory "LEDA-<ver>-<sys>-<cc>". You might want
to rename it or to move it to some different place. Let <leda-root-path>
denote the final complete path name of the LEDA root directory.

Now you have to modify your environment as follows:

a) LEDAROOT:
set the the environment variable LEDAROOT to <leda-root-path>

csh/tcsh: setenv LEDAROOT <leda-root-path>

sh/bash: LEDAROOT=<leda-root-path>
export LEDAROOT

b) Command Search Path:
include $LEDAROOT/Manual/cmd into your command search path (environment
variable path (csh) or PATH (sh)) and call "rehash" (if required by your
system).

c) Shared Libraries: (for solaris, linux, irix, osf1, hpux)
If you are planning to use shared libraries include $LEDAROOT into the
LD_LIBRARY_PATH search path (SHLIB_PATH for hpux). Then goto $LEDAROOT
and type "make shared". This will construct the shared libraries libL.so,
libG.so,libP.so,libW.so, and libD3.so (*.sl for hpux).

d) xlman and demos
go to $LEDAROOT and type "make xlman" to compile and link LEDA's
interactive manual reader "xlman".
"make demos" will compile all demo programs.
Now you can start "xlman" for reading and printing manual
pages, starting demo programs and browsing more release notes.



2. Compiling and linking application programs
---------------------------------------------

a) Use the -I compiler flag to tell the compiler where to find
the LEDA header files.

CC (g++) -I$LEDAROOT/incl -c file.c


b) Use the -L compiler flag to tell the compiler where to find
the libraries (libL.a/so, libG.a/so, ...)

CC (g++) -L$LEDAROOT file.o <libs>

<libs>:
-lL -lm (basic data types)
-lG -lL -lm (graph data types)
-lP -lG -lL -lm (planar geometry)
-lD3 -lP -lG -lL -lm (3d geometry)
-lW -lP -lG -lL -lX11 -lm (windows)

If using windows on solaris systems you might have to link with the
system socket library as well:
CC (g++) ... -lW -lP -lG -lL -lX11 -lsocket -lm


c) Compile and link simultaneously with

CC (g++) -I$LEDAROOT/incl -L$LEDAROOT file.c <libs>


You may want to ask your system adminstrator to install the
header files and libraries in the system's default directories.
Then you no longer have to specify header and library search paths
on the compiler command line.


3. More example programs and demos
----------------------------------

The source code of all example and demo programs can be found in
$LEDAROOT/test and $LEDAROOT/demo. Goto $LEDAROOT/test or
$LEDAROOT/demo and type "make" to compile and link all test or demo
programs, respectively.

4. User Manual
--------------
Go to $LEDAROOT and type "make man" to produce a postscript file
of the complete LEDA user manual ($LEDAROOT/Manual/MANUAL/MANUAL.ps).
All manual pages have been incorporated into the corresponding header
files. LEDA provides tools (see $LEDAROOT/Manual/MANUAL/README) to
extract and typeset the user manual from these files. Postscript and
HTML versions of the manual are also available at

http://www.mpi-sb.mpg.de/LEDA
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 7 749
24 mars 2010 à 11:03
Bon manifestement tu n'as pas compris ma dernière réponse et la documentation que tu viens de me copier coller. Je vais essayer d'être plus précise. En l'état actuel, dans quel répertoire as-tu dépaqueté LEDA ?

Bonne chance
0
non je compris ton question .j'ai fait la cmd: ""g++ -W -Wall -I/root/leda/incl/LEDA TOTO.c -o TOTO"" mais toujours le meme pbs.
et voila le chemin qui contient tous les FICHIER header LEDA :root/leda/incl/LEDA
0
mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 7 749
Modifié par mamiemando le 25/03/2010 à 15:04
Oui en fait le truc que je ne pouvais pas savoir quand je t'ai répondu, c'est qu'il faut linker ton application avec les librairies qu'elle utilise.

Pour compiler un module (.o), étant donné que tu inclues LEDA/header.h, il faut indiquer derrière l'option -I le répertoire qui contient le dossier LEDA. Ainsi ce serait plutôt :

g++ -W -Wall -I/root/leda/incl/ -c module.c


Pour compiler un exécutable (ajouter au besoin les modules utilisés dans cet exemple module1.o, module2.o), sur la même ligne :

g++ -W -Wall -I/root/leda/incl/ main.c -o executable module1.o module2.o -lG -lL -lm

(plus les éventuelles autres librairies dont tu pourrais avoir besoin, vu ton code je dirais que tu n'as besoin que de la partie graphe).

En cas de soucis reporte-moi les messages d'erreur de g++.

Je t'invite vivement à utiliser un makefile.

Bonne chance
0