Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOlved] how to include files easily?
Forum Updated to NodeBB v4.3 + New Features

[SOlved] how to include files easily?

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 2 Posters 2.9k 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.
  • P Offline
    P Offline
    pascal95abc
    wrote on 28 Apr 2012, 13:56 last edited by
    #1

    Hello,

    after having learnt how to use extern c++ files in project ("here":http://qt-project.org/forums/viewthread/16719/) I want to know how to include the header file if it is not in the same directory.
    I already tried adding the path with INCLUDEPATH like I did it before but for some reason I don't know it doesn't work.
    When I am in the code editor I can go to the definition of a function with CTRL+mouseclick but the compiler said
    mainwindow.cpp:111: error:undefined reference to `useful::power(double)'
    Additionally, I want to include the header file by including a file with no extension which includes my header file and is called Useful.

    I hope it is not wrong to create a new topic because I want to know how to link to these files in other directories and not what should be in them itself.

    Thank you

    Qt 4.7.3
    Symbian OS v9.4 / Symbian^1, S60 5th Edition
    on N97

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on 29 Apr 2012, 01:28 last edited by
      #2

      This is not a compile Error, it's a link Error which means that your header file has been found and your source code has been compiled successfully.
      [quote author="pascal95abc" date="1335621385"]but the compiler said
      mainwindow.cpp:111: error:undefined reference to `useful::power(double)'
      [/quote]

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on 29 Apr 2012, 01:42 last edited by
        #3

        [quote author="pascal95abc" date="1335621385"]
        Additionally, I want to include the header file by including a file with no extension which includes my header file and is called Useful.

        [/quote]

        1. Change the name of you current header file to "Useful" directly.

        2. Create a new file called "Useful", in which you include your old header file.

        BTW, I don't think it is good idea to use header file without .h/.hpp extension for user defined header files.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pascal95abc
          wrote on 29 Apr 2012, 07:20 last edited by
          #4

          I did not really get your explanations with creating the file Useful twice (?)

          So, this is the way my folder structure looks like:
          !http://o25.img-up.net/Screenshotnxk0.png(Projects/_useful/useful.h|useful.cpp|Useful)!

          If it is not possible to use Useful which includes useful.h then I will be ok with including useful.h directly.

          Qt 4.7.3
          Symbian OS v9.4 / Symbian^1, S60 5th Edition
          on N97

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dbzhang800
            wrote on 29 Apr 2012, 07:50 last edited by
            #5

            Ah, My fault. ;-)

            They are two methods, rather than two steps.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pascal95abc
              wrote on 29 Apr 2012, 07:58 last edited by
              #6

              actually, method 2 is the one I am using right now AND does not work
              I hope my picture made it clear how I want to have the structure.

              Qt 4.7.3
              Symbian OS v9.4 / Symbian^1, S60 5th Edition
              on N97

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pascal95abc
                wrote on 29 Apr 2012, 11:23 last edited by
                #7

                I really need this! I tried too much and nothing works!!!
                How can I do this ?! why is it so complicated?!

                Qt 4.7.3
                Symbian OS v9.4 / Symbian^1, S60 5th Edition
                on N97

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pascal95abc
                  wrote on 29 Apr 2012, 13:12 last edited by
                  #8

                  now this is solved
                  I have had a very simple idea:
                  #include actually just replaces the include command with the content of the specified file.
                  So I now have just a .cpp file with that simple content
                  @double sqr(douvle x){return x*x}@ and I include it.
                  So : no namespaces required ;)

                  Qt 4.7.3
                  Symbian OS v9.4 / Symbian^1, S60 5th Edition
                  on N97

                  1 Reply Last reply
                  0

                  1/8

                  28 Apr 2012, 13:56

                  • Login

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