Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] linking errors in Qt
Servers for Qt installer are currently down

[SOLVED] linking errors in Qt

Scheduled Pinned Locked Moved Qt Creator and other tools
32 Posts 4 Posters 13.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ogopa
    wrote on 2 Aug 2011, 16:11 last edited by
    #3

    wave.h:

    @#ifndef WAVE_H
    #define WAVE_H
    #include <alsa/asoundlib.h>
    #include <QMainWindow>

    namespace Ui {
    class wave;
    }

    class wave : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit wave(QWidget *parent = 0);
    ~wave();

    private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();
    

    private:
    Ui::wave *ui;
    };

    static int set_hwparams(snd_pcm_t *handle,
    snd_pcm_hw_params_t *params,
    snd_pcm_access_t access);
    static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams);
    static int write_loop(snd_pcm_t *handle,
    signed short *samples,
    snd_pcm_channel_area_t *areas);

    struct transfer_method {
    const char *name;
    snd_pcm_access_t access;
    int (*transfer_loop)(snd_pcm_t *handle,
    signed short *samples,
    snd_pcm_channel_area_t *areas);
    };

    static struct transfer_method transfer_methods[] = {

          { "write", SND_PCM_ACCESS_RW_INTERLEAVED, write_loop },
          { NULL, SND_PCM_ACCESS_RW_INTERLEAVED, NULL }
    

    };

    #endif // WAVE_H
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on 2 Aug 2011, 20:28 last edited by
      #4

      You can find some information "here":http://www.imb-jena.de/~gmueller/kurse/c_c++/c_linkag.html

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ogopa
        wrote on 2 Aug 2011, 20:52 last edited by
        #5

        [quote author="loladiro" date="1312316884"]You can find some information "here":http://www.imb-jena.de/~gmueller/kurse/c_c++/c_linkag.html[/quote]

        Hi loladiro, thanks for the reply. I took a look at your link and I have implemented the method explained in your link. When using write_loop in my main.cpp, i wrote: write_loop(h, samp, area);
        When using set_swparams, i wrote set_swparams(h, swparams)
        When using set_hwparams, i wrote set_hwparams(h, hwparams, transfer_methods[method].access)
        as shown in the posts above. but i am still getting the same errors. Please look at my posts above more carefully.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on 2 Aug 2011, 21:08 last edited by
          #6

          Is that all of your main.cpp? I'm confused as to how that is even a Qt app at all, except for your including the wave.h stuff.

          Your code is a teeny bit hard to read, and I'm not sure where the logic begins and the errors start... I don't mean that in a mean way, but only that it's a little hard to try to figure out what's supposed to be happening.

          Are you somehow trying to reimplement alsa function calls in your wave.cpp file? Inside the on_pushButton_clicked method?

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            ogopa
            wrote on 2 Aug 2011, 21:16 last edited by
            #7

            [quote author="mlong" date="1312319298"]Is that all of your main.cpp? I'm confused as to how that is even a Qt app at all, except for your including the wave.h stuff.

            Your code is a teeny bit hard to read, and I'm not sure where the logic begins and the errors start... I don't mean that in a mean way, but only that it's a little hard to try to figure out what's supposed to be happening.

            Are you somehow trying to reimplement alsa function calls in your wave.cpp file? Inside the on_pushButton_clicked method?

            [/quote]
            Sorry if its hard to read. I am trying to show that in wave.cpp, I have 3 functions in that file i.e. write_loop, set_swparams and set_hwparams. I have code inside the on_pushButton_clicked method. I am trying to implement alsa. However, that code seems to be running fine. But when I try to use the functions write_loop, set_swparams and set_hwparams in main.cpp, I am getting the errors main.o: In function main’: /home/test/Documents/Wave-build-desktop/../Wave/main.cpp:96: undefined reference to set_hwparams(_snd_pcm*, _snd_pcm_hw_params*, _snd_pcm_access)’
            /home/test/Documents/Wave-build-desktop/../Wave/main.cpp:101: undefined reference to set_swparams(_snd_pcm*, _snd_pcm_sw_params*)’ /home/test/Documents/Wave-build-desktop/../Wave/main.cpp:128: undefined reference to write_loop(_snd_pcm*, short*, _snd_pcm_channel_area*)’
            main.o:(.data+0×10): undefined reference to write_loop(_snd_pcm*, short*, _snd_pcm_channel_area*)’ moc_wave.o:(.data+0×10): undefined reference to write_loop(_snd_pcm*, short*, _snd_pcm_channel_area*)’
            collect2: ld returned 1 exit status.

            I have also implemented these functions in my header file. So what I am having a problem with is implementing these three functions in main.cpp.
            I hope this is a better explanation. Sorry

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on 2 Aug 2011, 21:25 last edited by
              #8

              You usually declare the methods or functions in a header file and implement it in a source file (.c or .cpp). Your problem has nothing to do with Qt (despite that the methods are called from some slot or the like).

              Are you really sure you have implemented the methods and that implementation is actually compiled?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on 2 Aug 2011, 21:29 last edited by
                #9

                I'm still confused as to you're redefining the functions in wave.cpp. They are already defined in the alsa library, no? It should just be a matter of calling the functions that already exist in the library, rather than creating your own versions.

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 2 Aug 2011, 21:35 last edited by
                  #10

                  Oh, it's alsa functions. Then it's essential to include the headers provided by alsa and link against the appropriate libraries. And it is a no-no to redeclare the functions in your own header file!

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mlong
                    wrote on 2 Aug 2011, 21:38 last edited by
                    #11

                    And we already discussed the linking "here.":http://developer.qt.nokia.com/forums/viewthread/8227/P15/ earier.

                    Software Engineer
                    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on 2 Aug 2011, 21:42 last edited by
                      #12

                      Ouch ... I didn't reach that post in my backlog reading :-)

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mlong
                        wrote on 2 Aug 2011, 21:44 last edited by
                        #13

                        It's ok. It took a while to drill down to exactly what the problem was, regardless. :-)

                        Software Engineer
                        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on 2 Aug 2011, 21:56 last edited by
                          #14

                          No problem. I'm on a huge backlog (or rather unread clicked away posts) due to some vacation.

                          So this thread can be closed?

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mlong
                            wrote on 2 Aug 2011, 22:01 last edited by
                            #15

                            I think we've probably gotten to the problem, but I imagine it depends on if ogopa feels like his question's been answered or not.

                            Software Engineer
                            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                            1 Reply Last reply
                            0
                            • O Offline
                              O Offline
                              ogopa
                              wrote on 3 Aug 2011, 13:36 last edited by
                              #16

                              [quote author="Volker" date="1312320331"]You usually declare the methods or functions in a header file and implement it in a source file (.c or .cpp). Your problem has nothing to do with Qt (despite that the methods are called from some slot or the like).

                              Are you really sure you have implemented the methods and that implementation is actually compiled?[/quote]

                              Sorry for my language it was wrong. I have defined the function in wave.cpp. I have declared it in the header file wave.h and I have called it in main.cpp. Isn't this the method used to call functions from my main.cpp to wave.cpp?

                              [quote author="mlong" date="1312320550"]I'm still confused as to you're redefining the functions in wave.cpp. They are already defined in the alsa library, no? It should just be a matter of calling the functions that already exist in the library, rather than creating your own versions.
                              [/quote]
                              I have defined functions that I wrote myself as it contains content that I wrote, it is not a predefined function that already exists in the alsa library. The functions I wrote are write_loop(), set_sw_params() and set_hwparams().

                              I'm really sorry for my terrible explanations so far.

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mlong
                                wrote on 3 Aug 2011, 17:57 last edited by
                                #17

                                Are you needing, perhaps, to put the static functions inside of your wave class, then? Then you could call them from main using wave::write_loop(), etc.? That seems like it might be a cleaner implementation than trying to deal with file scope and all kinds of C-like stuff.

                                Software Engineer
                                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  goetz
                                  wrote on 3 Aug 2011, 18:00 last edited by
                                  #18

                                  Are you sure your wave.cpp is compiled?

                                  http://www.catb.org/~esr/faqs/smart-questions.html

                                  1 Reply Last reply
                                  0
                                  • O Offline
                                    O Offline
                                    ogopa
                                    wrote on 3 Aug 2011, 18:18 last edited by
                                    #19

                                    [quote author="mlong" date="1312394247"]Are you needing, perhaps, to put the static functions inside of your wave class, then? Then you could call them from main using wave::write_loop(), etc.? That seems like it might be a cleaner implementation than trying to deal with file scope and all kinds of C-like stuff.
                                    [/quote]

                                    It doesn't allow functions to be placed inside a wave class.

                                    [quote author="Volker" date="1312394407"]Are you sure your wave.cpp is compiled?[/quote]
                                    Yes, i'm sure

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mlong
                                      wrote on 3 Aug 2011, 18:20 last edited by
                                      #20

                                      [quote author="ogopa" date="1312395537"]
                                      It doesn't allow functions to be placed inside a wave class.
                                      [/quote]

                                      What doesn't allow functions to be placed inside a wave class?

                                      Software Engineer
                                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on 3 Aug 2011, 18:22 last edited by
                                        #21

                                        Then I'm bailed out. We cannot guess, what's going on.

                                        I suggest, you boil down the problem to a small, yet complete and compilable test case and provide us the sources. Then we can have a look. Just add some dummy implementation for your functions.

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • O Offline
                                          O Offline
                                          ogopa
                                          wrote on 3 Aug 2011, 18:23 last edited by
                                          #22

                                          [quote author="mlong" date="1312395659"]
                                          [quote author="ogopa" date="1312395537"]
                                          It doesn't allow functions to be placed inside a wave class.
                                          [/quote]

                                          What doesn't allow functions to be placed inside a wave class?
                                          [/quote]

                                          Qt Creator doesn't allow to place functions inside a wave class for example inside a class of the pushbutton i.e mine is void on_pushButton_clicked().

                                          1 Reply Last reply
                                          0

                                          12/32

                                          2 Aug 2011, 21:42

                                          • Login

                                          • Login or register to search.
                                          12 out of 32
                                          • First post
                                            12/32
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved