Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QTextToSpeech causing multiple definitions errors
Forum Updated to NodeBB v4.3 + New Features

Using QTextToSpeech causing multiple definitions errors

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 845 Views 2 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.
  • S Offline
    S Offline
    Suroh6
    wrote on last edited by
    #1

    I was trying to follow the example code for QTextToSpeech from https://doc.qt.io/qt-5.10/qtspeech-hello-speak-example.html
    I modified it slightly but not in a way that should've broken anything. I get the following error when running the below code.

    Multiple definition of `Example::Example()`
    In function `QTypedArrayData<QVoice>::sharednull()`:
    

    This error occurs five times and references the same thing. Can anyone explain what's happening?

    #include "QTextToSpeech"
    class Example
    {
        public:
            Example();
            void speak(QString &words);
            void stop();
    
            void set_rate(int r);
            void set_pitch(int p);
            void set_volume(int v);
    
            void state_changed(QTextToSpeech::State state);
            void engine_selected(int index);
            void language_selected(int lang);
            void voice_selected(int index);
    
            void locale_changed(const QLocale &locale);
    
    
        protected:
    
    
        private:
            QTextToSpeech *example_speech;
            QVector<QVoice> vector_voices;
    
    };
    
    Example::Example()
    {
    
    }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      The implementation IS in the cpp file ?
      Example::Example()
      {

      }
      and not under class in .h as that would give multiple defines errors

      1 Reply Last reply
      3
      • S Offline
        S Offline
        Suroh6
        wrote on last edited by
        #3

        Sorry, I didn't realize that I didn't paste everything. Yes, it was in there, turns out for some reason there were multiple inclusions of the header and cpp in the .pro, once I removed those it took the errors away. I think it occurred when I modified it outside of the editor. I'm going to close this out!

        mrjjM 1 Reply Last reply
        2
        • S Suroh6

          Sorry, I didn't realize that I didn't paste everything. Yes, it was in there, turns out for some reason there were multiple inclusions of the header and cpp in the .pro, once I removed those it took the errors away. I think it occurred when I modified it outside of the editor. I'm going to close this out!

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Suroh6
          Ah, yes its a classic. If you use the New Class dialog and overwrite files
          this can easy happen.

          1 Reply Last reply
          1

          • Login

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