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. Compile error, cannot open output file, invalid argument
Servers for Qt installer are currently down

Compile error, cannot open output file, invalid argument

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 10.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.
  • Z Offline
    Z Offline
    Zerby
    wrote on 3 Jan 2014, 18:09 last edited by
    #1

    After working with my project today, I came across a wierd error:

    @:-1: error: cannot open output file debug\program.exe: Invalid argument
    collect2.exe:-1: error: error: ld returned 1 exit status@

    I've gotten rid of the message by "doing it all", cleaning, rebuilding, deleting the whole project/debug folder, even delete the whole output folder and then rebuild... The error might go away, but it will come back soon enough, and nothing seems to work. Then it just magically compiles.

    Needless to say I can't work like this, so has anyone ran into a similiar problem? Any suggestions?

    I'm working with client <> server communication atm, with sockets. I'm not sure if that has anything to do with anything.

    EDIT: Oh, almost forgot. I been looking at the debug folder while Qt Creator builds the project. Qt Creator never creates the .exe, only .tmp file, with random name for example trz81F0.tmp. Sometimes, earlier today, when I encountered the same problem, it sometimes created the .exe but it was 0 KB in size.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zerby
      wrote on 3 Jan 2014, 19:51 last edited by
      #2

      Hmm, now this is very bizarre!

      I've now pinpointed the cause. In my main() I have:

      @
      [......]
      QStringList files;
      connection->requestFiles(&files);
      QStringList hashed = connection->addHashes(files);
      [......]
      @

      In requestFiles the files stringlist is updated with filenames and addHashed returns another QStringList, using the files list's data.

      Now, if I compile my application with these lines, I get and .tmp file instead of the .exe, and so it doesn't work (compiler gives no errors). If I comment out the line:

      @QStringList hashed = connection->addHashes(files);@

      It compiles fine! Now this ofcouse got me thinking, and I created a new function my in connection -object (class patchServerConnection):

      @QStringList patchServerConnection::test(QStringList test)
      {
      QStringList list;
      list.append("asd");
      list.append("asdasd");
      return list;
      }@

      And so I ran:

      @
      [......]
      QStringList files;
      connection->requestFiles(&files);
      QStringList hashed = connection->test(files);
      [......]
      @

      And the problem again rises! Again, just a randomly named .tmp file in the output folder instead of the .exe. I've played around this alot, and have noticed now that every time I call a function from connection -object with QStringList as parameter, the compiler doesn't compile the exe correctly. If I create a function which returns a QStringList, but doesn't take a stringlist as parameter, it works. Also:

      1. I've tried with a different QStringList, I mean not using the files -named object.
      2. I tried with void test(QStringList test = QStringList()); and then calling only connection->test(); Still doesn't work.

      Now, I can go around this problem for now it seems, by changing addHashes to take a QStringList as a pointer instead of returning the list. But still, whaaaaat on earth causes this behavior? Anyone have any clues??

      EDIT: Well, actually I can't go around it, as I ofcourse do have to pass the files -QStringlist to addHashes... Damn it! Please, I need help :(

      EDIT2: Well, I don't think it has anything to do with anything really. I do a workaround of some sort, get it to compile. Start working like normal again, and again at random time it hangs up with the error

      @:-1: error: cannot open output file debug\program.exe: Invalid argument
      collect2.exe:-1: error: error: ld returned 1 exit status@

      And yet again if I change some random thing here or there it starts to work. What the hell?!

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Jan 2014, 21:04 last edited by
        #3

        Hi,

        What version of Qt are you using ? On which OS with which compiler ?
        What is the complete error log ? Also are you sure you are including QStringList properly where needed ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          Zerby
          wrote on 3 Jan 2014, 22:13 last edited by
          #4

          Phew, I wrote just a long post (again...), and just before hitting post reply I noticed something. I hadn't added a file that I had included, in to my project. The file is basic globals type file, constant QStrings mostly. It's strange the compiler didn't give any error about it though.

          After adding it to my project, I've now been able to go forward without errors for some time. I'm pretty positive that was the cause.

          Thank you SGaist, you guided me toward the solution with your comment about QStringList includes. I played a lot with includes for QStringList, but as it seems, it wasn't actually QStringList that was causing the problem, although it seemed likely at first.

          This is now probably solved, I'll update the topic header after some more testing, just to be sure..

          1 Reply Last reply
          0

          1/4

          3 Jan 2014, 18:09

          • Login

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