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.!0_1513184974512_Schermata 2017-12-13 alle 17.59.57.png image url)


  • Lifetime Qt Champion

    Hi,

    Take a look at the compiler panel, what exact symbol is missing ?



  • Sorry but i'm new to Qt and i'm new to C++ also :)


  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

    Where are these methods implemented ?



  • I've implemented the methods into the main file, and i create an header file in witch i declared the variables.



  • @Gabry80 In order to give help it would be necessary to see the code from main (main.cpp / main.h)



  • 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 indirizzo

    namespace Ui {
    class Pointer1;

    }

    class Pointer1 : public QMainWindow
    {
    Q_OBJECT

    public:
    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;
    

    }


  • Qt Champions 2017

    @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 indirizzo

    This is only the defintion.
    Where are the bodies ?
    Like
    int sommaVal(int a, int b) {
    ..code...
    }
    seems not to be in main.cpp ?



  • I should review the code...


  • Qt Champions 2017

    @Gabry80
    Yep and find the missing implementations :)



  • I have reviewed the code and solved the issues,thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.