Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Moved] how to use pthread in qt??
Qt 6.11 is out! See what's new in the release blog

[Moved] how to use pthread in qt??

Scheduled Pinned Locked Moved C++ Gurus
6 Posts 4 Posters 6.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.
  • S Offline
    S Offline
    shakthi
    wrote on last edited by
    #1

    am using qt in windows. but i like to develop one linux application with the help of qt..... can anyone tell me how to use pthread in qt?? i got some few errors.. please dont mention to use QThreads... got two errors:

    1. error in third argument - pthread_create(&thread2,NULL,(void*)&even,NULL);
    2. undefined error while building. like undefiend error in pthread_mutex_lock....... in linux am using -lpthread, so how to add those libpthread.so.0 in qt..........

    kindly help me soon .. its urgent..

    thanks in advance,
    shakthi

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Show the exact errors, not just your interpretation of them.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

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

        pthread_create(&thread1,NULL,(void*)&even,NULL);

        error:

        • invalid conversion from void* to (void*)()(void)
        • initalizing argument in pthread_create(....)

        the above are errors in first level

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on last edited by
          #4

          What type has "even"?
          Just seems you need:
          @pthread_create(&thread1,NULL,(void *)even,NULL);@

          --
          Vasiliy

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franzk
            wrote on last edited by
            #5

            I think you need to pass in a function that accepts a void pointer:
            @void even(void*);@

            Even if you don't use the pointer, the function has to accept it to match the function type expected by pthread_create
            @void *(start_routine)(void)@
            as stated in the "pthread_create man page":http://linux.die.net/man/3/pthread_create. If that doesn't fix it, please provide a zipped project with your code or code that shows the exact issue you have, so we can try and debug ourselves.

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              Moved to the C++ Gurus forum, this has nothing to do with Qt.

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

              1 Reply Last reply
              0

              • Login

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