Salut tlm
j'ai un problème d'édition de lien sous Linux
j ai un objet compilé (test.o) avec gcc qui offre une fonction f() écrite en C . je veux utiliser cette fonction dans C++.
j'ai fais un petit test qui me renvoies une erreur
[adel@laptotAdel ml]$ gcc -c test.c
[adel@laptotAdel ml]$ g++ -c main.cpp
In file included from /usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/backward/iostream.h:31,
from main.cpp:1:
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../../include/c++/4.0.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
[adel@laptotAdel ml]$ g++ main.o test.o
main.o(.text+0x1d): In function `main':
main.cpp: undefined reference to `f()'
collect2: ld a retourné 1 code d'état d'exécution
et voici le code
[adel@laptotAdel ml]$ cat test.c
int f(){
return 0;
}
[adel@laptotAdel ml]$ cat main.cpp
#include <iostream.h>
main(){
int f();
cout << f() << endl;
return 0;
}
Partager