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. Declaration of function and use it
Forum Updated to NodeBB v4.3 + New Features

Declaration of function and use it

Scheduled Pinned Locked Moved Unsolved General and Desktop
93 Posts 4 Posters 60.0k 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.
  • G gauravsharma0190

    @mrjj
    it is defined as

    ///ontrack.h///
    
    #ifndef __ONTRACK_h
    #define __ONTRACK_h
    void cannyThresold(int,void*);
    #endif
    ......
    
    ///ontrack.cpp
    #include "ontrack.h"
    #include<opencv2/opencv.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/core/core.hpp>
    void CannyThreshold(int, void*)
    {
    /// Reduce noise with a kernel 3x3
    blur( src_gray, detected_edges, Size(3,3) );
    /// Canny detector
    Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
    
    /// Using Canny's output as a mask, we display our result
    dst = Scalar::all(0);
    
    src.copyTo( dst, detected_edges);
    imshow( window_name, dst );
    }
    

    .....
    thus i include ontrack.h in mainwindow.cpp code.
    but error occurs.
    Why??
    i can't understand.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #46

    @gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    mrjjM G 2 Replies Last reply
    1
    • jsulmJ jsulm

      @gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.

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

      @jsulm
      heh Good spotted. completely missed "old" :)

      G 1 Reply Last reply
      1
      • mrjjM mrjj

        @jsulm
        heh Good spotted. completely missed "old" :)

        G Offline
        G Offline
        gauravsharma0190
        wrote on last edited by
        #48

        @mrjj
        I fix canny as Canny in .h file
        but again error occurs.

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.

          G Offline
          G Offline
          gauravsharma0190
          wrote on last edited by
          #49

          @jsulm
          Hey i fixed it .But again error.

          jsulmJ 1 Reply Last reply
          0
          • G gauravsharma0190

            @jsulm
            Hey i fixed it .But again error.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #50

            @gauravsharma0190 "But again error" - why don't you say what error you get now?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            G 1 Reply Last reply
            2
            • jsulmJ jsulm

              @gauravsharma0190 "But again error" - why don't you say what error you get now?

              G Offline
              G Offline
              gauravsharma0190
              wrote on last edited by
              #51

              @jsulm
              yes it tells undefined reference to 'CannyThresold(int,void*)'.
              collect2:error ld returned 1 exit status.

              jsulmJ 1 Reply Last reply
              0
              • G gauravsharma0190

                @jsulm
                yes it tells undefined reference to 'CannyThresold(int,void*)'.
                collect2:error ld returned 1 exit status.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #52

                @gauravsharma0190 Is ontrack.cpp part of your project and is it built?
                "undefined reference to 'CannyThresold(int,void*)" - means linker cannot find CannyThresold(int,void*)

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @gauravsharma0190 Is ontrack.cpp part of your project and is it built?
                  "undefined reference to 'CannyThresold(int,void*)" - means linker cannot find CannyThresold(int,void*)

                  G Offline
                  G Offline
                  gauravsharma0190
                  wrote on last edited by
                  #53

                  @jsulm
                  Actually i put .h and .cpp file in my qt project folder.

                  jsulmJ 1 Reply Last reply
                  0
                  • G gauravsharma0190

                    @jsulm
                    Actually i put .h and .cpp file in my qt project folder.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #54

                    @gauravsharma0190 But did you add them to your project?
                    They should be in the PRO file, like:

                    SOURCES += main.cpp\
                            mainwindow.cpp\
                            ontrack.cpp
                    
                    HEADERS  += mainwindow.h\
                            ontrack.h
                    

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    G 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @gauravsharma0190 But did you add them to your project?
                      They should be in the PRO file, like:

                      SOURCES += main.cpp\
                              mainwindow.cpp\
                              ontrack.cpp
                      
                      HEADERS  += mainwindow.h\
                              ontrack.h
                      
                      G Offline
                      G Offline
                      gauravsharma0190
                      wrote on last edited by
                      #55

                      @jsulm
                      i added it but gives error as
                      parse error onTrack.cpp
                      Makefile error 3

                      jsulmJ 1 Reply Last reply
                      0
                      • G gauravsharma0190

                        @jsulm
                        i added it but gives error as
                        parse error onTrack.cpp
                        Makefile error 3

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #56

                        @gauravsharma0190 After changing PRO file you need to rerun qmake (right-click on the project in QtCreator and then "Run qmake". Then do a rebuild.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        G 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @gauravsharma0190 After changing PRO file you need to rerun qmake (right-click on the project in QtCreator and then "Run qmake". Then do a rebuild.

                          G Offline
                          G Offline
                          gauravsharma0190
                          wrote on last edited by
                          #57

                          @jsulm
                          I done it
                          Now gives many error regarding onTrack.cpp file.

                          jsulmJ 1 Reply Last reply
                          0
                          • G gauravsharma0190

                            @jsulm
                            I done it
                            Now gives many error regarding onTrack.cpp file.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #58

                            @gauravsharma0190 Well, I guess you have many issues there...

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            G 3 Replies Last reply
                            0
                            • jsulmJ jsulm

                              @gauravsharma0190 Well, I guess you have many issues there...

                              G Offline
                              G Offline
                              gauravsharma0190
                              wrote on last edited by
                              #59

                              @jsulm
                              Yeap.
                              are they function's issuses or anything.
                              I can't undersatnd everything is all right so Why all these issuses are there.
                              I will send you these issue.

                              G 1 Reply Last reply
                              0
                              • G gauravsharma0190

                                @jsulm
                                Yeap.
                                are they function's issuses or anything.
                                I can't undersatnd everything is all right so Why all these issuses are there.
                                I will send you these issue.

                                G Offline
                                G Offline
                                gauravsharma0190
                                wrote on last edited by
                                #60

                                @gauravsharma0190
                                Here are all the errors
                                ...

                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'blur' was not declared in this scope
                                     blur(gray, edge, Size(3,3));
                                                               ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:6: error: 'Mat' does not name a type
                                 Mat image, gray, edge, cedge;
                                 ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:7: error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive]
                                   static void CannyThreshold(int, void*)
                                                                        ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:-1: In function 'void CannyThreshold(int, void*)':
                                
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'edge' was not declared in this scope
                                     blur(gray, edge, Size(3,3));
                                                ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'edge' was not declared in this scope
                                     blur(gray, edge, Size(3,3));
                                                ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'blur' was not declared in this scope
                                     blur(gray, edge, Size(3,3));
                                                               ^
                                
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:12: error: 'Canny' was not declared in this scope
                                     Canny(edge, edge, edgeThresh, edgeThresh*3, 3);
                                                                                  ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:13: error: 'cedge' was not declared in this scope
                                     cedge = Scalar::all(0);
                                     ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:15: error: 'src' was not declared in this scope
                                     src.copyTo(cedge, edge);
                                     ^
                                /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:16: error: 'imshow' was not declared in this scope
                                     imshow("Edge map", cedge);
                                                             ^
                                /usr/local/include/opencv2/highgui/highgui.hpp:78: note:   'cv::imshow'
                                 CV_EXPORTS_W void imshow(const string& winname, InputArray mat);
                                
                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @gauravsharma0190 Well, I guess you have many issues there...

                                  G Offline
                                  G Offline
                                  gauravsharma0190
                                  wrote on last edited by
                                  #61
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @gauravsharma0190 Well, I guess you have many issues there...

                                    G Offline
                                    G Offline
                                    gauravsharma0190
                                    wrote on last edited by
                                    #62

                                    @jsulm
                                    Hey i have posted the error
                                    i can't undersatnd why i am getting these error.
                                    everything is all right.

                                    jsulmJ 1 Reply Last reply
                                    0
                                    • G gauravsharma0190

                                      @jsulm
                                      Hey i have posted the error
                                      i can't undersatnd why i am getting these error.
                                      everything is all right.

                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by jsulm
                                      #63

                                      @gauravsharma0190 Nothing is all right with this code.
                                      "was not declared in this scope" - you have to check where are those declared or why they are not declared (blur, edge, Mat,...). For example:

                                      cedge = Scalar::all(0);
                                      

                                      where is cedge declared? You're trying to access a variable which was not declared.

                                      This one says that you first declared the function extern and later static. Why? Since it is just a function it neither has to be static nor extern!

                                      error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive]
                                         static void CannyThreshold(int, void*)
                                      

                                      You really have to fix your code! And I really don't understand why you think your code is OK although there are really basic issues (not related to Qt at all)!

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      G 1 Reply Last reply
                                      1
                                      • jsulmJ jsulm

                                        @gauravsharma0190 Nothing is all right with this code.
                                        "was not declared in this scope" - you have to check where are those declared or why they are not declared (blur, edge, Mat,...). For example:

                                        cedge = Scalar::all(0);
                                        

                                        where is cedge declared? You're trying to access a variable which was not declared.

                                        This one says that you first declared the function extern and later static. Why? Since it is just a function it neither has to be static nor extern!

                                        error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive]
                                           static void CannyThreshold(int, void*)
                                        

                                        You really have to fix your code! And I really don't understand why you think your code is OK although there are really basic issues (not related to Qt at all)!

                                        G Offline
                                        G Offline
                                        gauravsharma0190
                                        wrote on last edited by
                                        #64

                                        @jsulm
                                        i declare all these variable inside onTrach.cpp file.
                                        blur is function name which is in imgproc.hpp header.
                                        Canny is also function name which is declared in highgui.h header.

                                        jsulmJ 1 Reply Last reply
                                        0
                                        • G gauravsharma0190

                                          @jsulm
                                          i declare all these variable inside onTrach.cpp file.
                                          blur is function name which is in imgproc.hpp header.
                                          Canny is also function name which is declared in highgui.h header.

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #65

                                          @gauravsharma0190
                                          Can you post onTrach.cpp and onTrach.h?

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          G 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