Error: :-1: error: symbol(s) not found for architecture x86_64; :-1: error: linker command failed with exit code 1 (use -v to see invocation)
-
Hello, i'm writing some code for school purposes, i create a Qt widget application, when i run the project i get the errors reported in the Title, the platform i'm using is MAC.I have a screenshot of the issue.I guess if anybody can help me.Thank You.! image url)
-
Hi,
Take a look at the compiler panel, what exact symbol is missing ?
-
No problem with that. But without the information I'm asking, it's going to be difficult to help you.
-
This is the compile output(i hope it helps):
11:54:01: Running steps for project Puntatori1...
11:54:01: Configuration unchanged, skipping qmake step.
11:54:01: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wl,-rpath,@executable_path/Frameworks -Wl,-rpath,/Users/gabrielmometti/Qt/5.9.2/clang_64/lib -o Puntatori1.app/Contents/MacOS/Puntatori1 main.o pointer1.o moc_pointer1.o -F/Users/gabrielmometti/Qt/5.9.2/clang_64/lib -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
Undefined symbols for architecture x86_64:
"sommaPun(int*, int*)", referenced from:
_main in main.o
"sommaRif(int&, int&)", referenced from:
_main in main.o
"sommaVal(int, int)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Puntatori1.app/Contents/MacOS/Puntatori1] Error 1
11:54:01: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Puntatori1 (kit: Desktop Qt 5.9.2 clang 64bit)
When executing step "Make"
11:54:01: Elapsed time: 00:00. -
Where are these methods implemented ?
-
This is the pointer1.h (Header file)
#ifndef POINTER1_H
#define POINTER1_H#include <QMainWindow>
int sommaVal(int a, int b); //parametri passati per valore
int sommaPun(int *a, int *b); //parametri passati per puntatore
int sommaRif(int &a, int &b); //parametri passati come indirizzonamespace Ui {
class Pointer1;}
class Pointer1 : public QMainWindow
{
Q_OBJECTpublic:
explicit Pointer1(QWidget *parent = 0);
~Pointer1();private:
Ui::Pointer1 *ui;
};#endif // POINTER1_H
And, this is the Main.cpp
#include "pointer1.h"
#include <QApplication>
#include <string>
#include <iostream>using namespace std;
int main()
{
int a = 5;
int b = 4;
char carattere;
int rrr = sommaVal(a,b);
cout << "Risultato(Val)=" << rrr << endl;
cout << "a =" << a << endl;
cout << "b =" << b << endl;
cout << "-----------" << endl;
rrr = sommaPun(&a,&b);
cout << "Risultato(Pun)=" << rrr << endl;
cout << "a =" << a << endl;
cout << "b =" << b << endl;
cout << "-----------" << endl;
rrr = sommaRif(a,b);
cout << "Risultato(Rif)=" << rrr << endl;
cout << "a =" << a << endl;
cout << "b =" << b << endl;fflush(stdin); scanf("%c", &carattere); int r; r = a+b-1; a = 3; b = 6; return r;
/* int s = *a+*b-1;
*a = 3;
*b = 6;return s;
*/
int t = a+b-1;
a = 4;
b = 6;return t;
}
-
@Gabry80 said in Error: :-1: error: symbol(s) not found for architecture x86_64; :-1: error: linker command failed with exit code 1 (use -v to see invocation):
int sommaVal(int a, int b); //parametri passati per valore
int sommaPun(int *a, int *b); //parametri passati per puntatore
int sommaRif(int &a, int &b); //parametri passati come indirizzoThis is only the defintion.
Where are the bodies ?
Like
int sommaVal(int a, int b) {
..code...
}
seems not to be in main.cpp ?