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. How do I get a text file to copy into a build?
Forum Updated to NodeBB v4.3 + New Features

How do I get a text file to copy into a build?

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 15.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.
  • D Offline
    D Offline
    doozii
    wrote on last edited by
    #4

    Windows 7

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #5

      If you are using QtCreator then you can add one more build step on the "Projects" tab.
      This step will be written into .pro.user file and will be OS specific.

      If you are going to build your project manually by run qmake and make then you may need to run make install after successful build.
      "Take a look here":http://stackoverflow.com/questions/7795397/copy-a-file-to-the-build-directory-after-compiling-project-with-qt

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doozii
        wrote on last edited by
        #6

        Thank you for your reply andreyc. Can you provide info on exactly what/how to add the build step?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #7
          1. Click on "Projects" icon on sidebar
          2. See the "Build Steps" in the "Build Settings"
          3. Click "Add Build Step" button
          4. Select "Custom build step"
          5. In the "Commands" field enter your copy command. Command only without args.
          6. In "Arguments" field enter %{sourceDir}/YourFile %{buildDir}
          7. Go back to "Edit" and try to build your project

          "Here is more info":https://qt-project.org/doc/qtcreator-3.0/creator-build-settings.html

          PS: I use Linux, so I did not try it to run on Windows. YMMV.

          1 Reply Last reply
          3
          • D Offline
            D Offline
            doozii
            wrote on last edited by
            #8

            Thats great! Now we are making progress. I tried to enter "copy" in the commands field but I got an error: The process copy exited with code of -1.

            What is the correct copy command?

            Sorry for all the trouble... just needing to learn this fast and cant find any good explanations on Google or StackOverflow or in the qt forum and have been searching for days.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #9

              I don't have an access to windows machine right now and don't remember the format of the copy command.
              You can try to run copy /? in command prompt to see the correct format.

              Could you show the full log message that you get in QtCreator on this error?

              1 Reply Last reply
              0
              • D Offline
                D Offline
                doozii
                wrote on last edited by
                #10

                Wait... are we talking about the OS copy command? Or something in QT Creator?
                Yeah, Ill post

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  doozii
                  wrote on last edited by
                  #11

                  11:38:39: Starting: "COPY" C:\WORKSPACE\MyProject\MyFile.json C:\WORKSPACE\build-MyProject-Desktop_Qt_5_2_1_MSVC2012_OpenGL_64bit-Debug
                  qtcreator_ctrlc_stub: Command line failed: COPY C:\WORKSPACE\MyProject\MyFile.json C:\WORKSPACE\build-MyProject-Desktop_Qt_5_2_1_MSVC2012_OpenGL_64bit-Debug
                  11:38:39: The process "COPY" exited with code -1.
                  Error while building/deploying project MyProject (kit: Desktop Qt 5.2.1 MSVC2012 OpenGL 64bit)
                  When executing step 'Custom Process Step'

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    doozii
                    wrote on last edited by
                    #12

                    I ran the command directly on the command line and it worked just fine but not from QT Creator

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andreyc
                      wrote on last edited by
                      #13

                      Do you have this file and this directory in place during build?
                      Another option is try to run dir instead of copy just to make sure that QtCreator sees the file and the directory the same way as you see them when you run command manually.

                      And yes these are OS commands.
                      You can create a script and put in your project directory and run it.
                      You will need to put full path to the script in the "Commands" field.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        doozii
                        wrote on last edited by
                        #14

                        Yes sir, everything is in place. When I run the copy form the command line it performs the copy. Do I need to setup something in QT Creator that tells it where the system OS commands are located? I see in Options > Environment >External tools but not sure what would need to go there. If I click Add >Tool it puts in a New Uncategorized tool with the executable cmd and arguments /c echo Useful text. Is this what QTC is missing? Some reference to where the COPY command is located?

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andreyc
                          wrote on last edited by
                          #15

                          No you don't need to change the "External Tools"
                          Did you try to run dir command instead of copy?
                          I think copy is not located anywhere it is just part of cmd.exe
                          Which makes me think that maybe you should call cmd.exe with some options that will allow to execute copy.
                          Try cmd.exe /? and see if it has an option to run command from command line.
                          Something like
                          @
                          cmd.exe /c copy src dst
                          @

                          If it will work in command prompt then put cmd.exe into "Command" field and "/c copy src dst" into "Arguments" field in your "Custom build step".

                          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