CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

[C++] erreur compilation

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 18:47:04

Bonjour,

J'ai un fichier .cpp à compiler sur mon macbook (intel), mais lorsque j'utilise la commande :
gcc pilote_lu.cpp -o test
Le terminal m'affiche l'erreur suivante:
Undefined symbols for architecture x86_64:

avec beaucoup d'erreurs comme:
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
_main in ccqgM7Ks.o

Quelqu'un a t-il une idée du problème ? (j'utilise la dernière version de gcc)

Merci d'avance, cordialement.

godrik
godrik
Niveau 30
30 octobre 2012 à 18:52:58

donnes un code complet ici: http://wall.deblan.fr/

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 18:57:55
  1. include <string>
  2. include <fstream>
  3. include <iostream>
  4. include <stdlib.h>
  5. include <iomanip>
  6. include "/Users/pierrechapuis/Documents/UNIVERSITE/Master/

M1/Calculs
Intensifs/nr2/share/nr.h"

using namespace std;

// Driver for routine ludcmp

int main(void)
{
int j,k,l,m,n,dum;
string txt;
DP d;
ifstream fp("matrx1.dat");

if (fp.fail())
NR::nrerror("Data file matrx1.dat not found");
cout << fixed << setprecision(6);
getline(fp,txt);
while (!fp.eof()) {
getline(fp,txt);
fp >> n >> m;
getline(fp,txt);
Vec_INT indx(n),jndx(n);
Mat_DP a(n,n),xl(n,n),xu(n,n),x(n,n);
getline(fp,txt);
for (k=0;k<n;k++)
for (l=0;l<n;l++) fp >> a[k][l];
getline(fp,txt);
getline(fp,txt);
for (l=0;l<m;l++)
for (k=0;k<n;k++) fp >> x[k][l];
getline(fp,txt);
getline(fp,txt);
// Print out a-matrix for comparison with product of
// lower and upper decomposition matrices
cout << "original matrix:" << endl;
for (k=0;k<n;k++) {
for (l=0;l<n;l++) cout << setw(12) << a[k][l];
cout << endl;
}
// Perform the decomposition
NR::ludcmp(a,indx,d);
// Compose separately the lower and upper matrices
for (k=0;k<n;k++) {
for (l=0;l<n;l++) {
if (l > k) {
xu[k][l]=a[k][l];
xl[k][l]=0.0;
} else if (l < k) {
xu[k][l]=0.0;
xl[k][l]=a[k][l];
} else {
xu[k][l]=a[k][l];
xl[k][l]=1.0;
}
}
}
// Compute product of lower and upper matrices for
// comparison with original matrix
for (k=0;k<n;k++) {
jndx[k]=k;
for (l=0;l<n;l++) {
x[k][l]=0.0;
for (j=0;j<n;j++)
x[k][l] += (xl[k][j]*xu[j][l]);
}
}
cout << endl << "product of lower and upper ";
cout << "matrices (rows unscrambled):" << endl;
for (k=0;k<n;k++) {
dum=jndx[indx[k]];
jndx[indx[k]]=jndx[k];
jndx[k]=dum;
}
for (k=0;k<n;k++)
for (j=0;j<n;j++)
if (jndx[j] == k) {
for (l=0;l<n;l++)
cout << setw(12) << x[j][l];
cout << endl;
}
cout << endl << "lower matrix of the decomposition:" << endl;
for (k=0;k<n;k++) {
for (l=0;l<n;l++)
cout << setw(12) << xl[k][l];
cout << endl;
}
cout << endl << "upper matrix of the decomposition:" << endl;
for (k=0;k<n;k++) {
for (l=0;l<n;l++) cout << setw(12) << xu[k][l];
cout << endl;
}
cout << endl << "***********************************" << endl;
cout << "press return for next problem:" << endl;
cin.get();
}
fp.close();
return 0;
}

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 18:58:43

Je n'ai pas compris comment l'envoyer sur wall.deblan godrik, donc je l'ai posté ici. C'est le .cpp

godrik
godrik
Niveau 30
30 octobre 2012 à 19:00:23

C'est du c++, il faut le compiler avec g++ pas gcc.

gcc pilote_lu.cpp -o test

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 19:04:35

En utilisant g++ il m'affiche :

pc2:LU pierrechapuis$ g++ pilote_lu.cpp -o test
Undefined symbols for architecture x86_64:
"NR::ludcmp(NRMat<double>&, NRVec<int>&, double&)", referenced from:
_main in cceauhdQ.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

J'ai passé à un souci de compilation 64 bits au lieu de 32 bits ? est-ce possible ?

Merci de ton aide en tout cas :)

godrik
godrik
Niveau 30
30 octobre 2012 à 19:11:47

ou est defini la fonction NR::ludcmp ?

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 19:19:43

Ah ! grâce à toi j'ai trouvé mon problème, je crois.
Le "ludcmp" c'est un .cpp, et apparemment il appelle un .h qui est mal défini (son chemin ne correspond pas à celui de mon ordinateur, car le programme vient d'un professeur).
Je vais changer le chemin d'accès dedans, et je te dis si c'est bon, ou pas.

Merci bien !

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 19:23:40

Bon apparemment ce n'est pas ça. Toujours pareil.
Le NR::ludcmp est défini dans le ludcmp.cpp, dans le meme dossier que mon .cpp que je compile. Il y a également un fichier ludcmp.o dans ce dossier.
Voici le ludcmp.cpp :

  1. include <cmath>
  2. include <stdlib.h>
  3. include "/Users/pierrechapuis/Documents/UNIVERSITE/Master/

M1/Calculs
Intensifs/nr2/share/nr.h"

using namespace std;

void NR::ludcmp(Mat_IO_DP &a, Vec_O_INT &indx, DP &d)
{
const DP TINY=1.0e-20;
int i,imax,j,k;
DP big,dum,sum,temp;

int n=a.nrows();
Vec_DP vv(n);
d=1.0;
for (i=0;i<n;i++) {
big=0.0;
for (j=0;j<n;j++)
if ((temp=fabs(a[i][j])) > big) big=temp;
if (big == 0.0) nrerror("Singular matrix in routine ludcmp");
vv[i]=1.0/big;
}
for (j=0;j<n;j++) {
for (i=0;i<j;i++) {
sum=a[i][j];
for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
a[i][j]=sum;
}
big=0.0;
for (i=j;i<n;i++) {
sum=a[i][j];
for (k=0;k<j;k++) sum -= a[i][k]*a[k][j];
a[i][j]=sum;
if ((dum=vv[i]*fabs(sum)) >= big) {
big=dum;
imax=i;
}
}
if (j != imax) {
for (k=0;k<n;k++) {
dum=a[imax][k];
a[imax][k]=a[j][k];
a[j][k]=dum;
}
d = -d;
vv[imax]=vv[j];
}
indx[j]=imax;
if (a[j][j] == 0.0) a[j][j]=TINY;
if (j != n-1) {
dum=1.0/(a[j][j]);
for (i=j+1;i<n;i++) a[i][j] *= dum;
}
}
}

godrik
godrik
Niveau 30
30 octobre 2012 à 19:38:46

C'est un probleme de linkage que tu as. Tu n'as jamais suivi comment faire de la programmatin modulaire? Basiquement chaque fichier .c ou .cpp genere un fichier .o. ensuite il faut utiiser les fichiers .o pour generer un binaire. Make fait ca pour toi. regarde ce cours:

http://www.cs.miami.edu/~geoff/Courses/CSC322-11S/Content/CTools/Make.shtml

Pierre-Spartan
Pierre-Spartan
Niveau 6
30 octobre 2012 à 19:41:10

Non non je débute dans ce domaine.
Ok je vais regarder ton cours ! Merci bien godrik pour ton aide !

Sous forums
  • Aide à l'achat Mac
  • Macintosh
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Steam Deck
  • Hardware
La vidéo du moment