Results 1 to 6 of 6

Thread: Release mode does not work properly with .bin file opening

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    3
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Release mode does not work properly with .bin file opening

    Hello,

    I asked a question sometime back, and none answered , I managed to solve the problem by myslef but now I have no idea, and google can't help me much either.

    The problem is, my code works fine when I run on debug mode, it opens my .bin files I need to open, perfect.

    Although when I try to run on release mode (which I need so I can send the work to my teacher to test and grade) it runs everything alright, except for the file manipulation (opening .bin files in this case), it just won't open my files, I have no ideia why. And yes, the .bin files are on the same directory, I'm trying with the right name too, but it always returns NULL if I check the file pointer.

    I'm using the basic stdio.h, so fopen is the opening function, FILE *arq is my pointer, but I can't manage to make it work on release mode. I think there is some library link missing, or something like that, though I don't know exactly, because I'm still a beginner on this subject.

    Hope you can understand the question, if you can't, please tell me what you need in a more clear way, so that I can explain, and understand what is wrong.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Release mode does not work properly with .bin file opening

    Quote Originally Posted by Lonatico View Post
    I'm using the basic stdio.h, so fopen is the opening function, FILE *arq is my pointer
    What is the reason you are asking this question on a Qt forum then?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Release mode does not work properly with .bin file opening

    Not that this has anything to do with Qt, but if fopen() cannot find the file it will return NULL and set errno to one of many values outlined in the man page for open(2). If you are using a relative path for the file, e.g. "file.bin" and not "/full/path/to/file.bin", then make sure the current working directory of the process is where you think it is.

    If you are building/running your non-Qt program from Qt Creator on Windows (a wild guess) then the default working directory for a release executable is different to that for a debug build.

  4. #4
    Join Date
    Aug 2013
    Posts
    3
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Re: Release mode does not work properly with .bin file opening

    Quote Originally Posted by wysota View Post
    What is the reason you are asking this question on a Qt forum then?
    Because with everything else works fine. I have done some code in Codeblocks and the fopen functions work fine, it is only with Qt .exe in release mode that this is happening, so I wondered if there was no problem concerning Qt itself. I'm sorry if I asked in the wrong place, moderators feel free to delete this thread if you think it does not apply to the forum

    Quote Originally Posted by ChrisW67 View Post
    Not that this has anything to do with Qt, but if fopen() cannot find the file it will return NULL and set errno to one of many values outlined in the man page for open(2). If you are using a relative path for the file, e.g. "file.bin" and not "/full/path/to/file.bin", then make sure the current working directory of the process is where you think it is.

    If you are building/running your non-Qt program from Qt Creator on Windows (a wild guess) then the default working directory for a release executable is different to that for a debug build.
    It seems to be on the right place. Yes I'm using Windows. I'm placing the .bin files inside the release directory, where the .exe is.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Release mode does not work properly with .bin file opening

    Quote Originally Posted by Lonatico View Post
    Because with everything else works fine. I have done some code in Codeblocks and the fopen functions work fine, it is only with Qt .exe in release mode that this is happening, so I wondered if there was no problem concerning Qt itself.
    All information we have suggests that you are not using Qt. So even if there were a problem in Qt itself, which is highly unlikely since many others would be impacted as well and no such reports have come up, there would still be no relation to your problem.

    If you are using Qt somehow then it would be helpful to know what of Qt you are using.

    Cheers,
    _

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Release mode does not work properly with .bin file opening

    Quote Originally Posted by Lonatico View Post
    It seems to be on the right place. Yes I'm using Windows. I'm placing the .bin files inside the release directory, where the .exe is.
    What does that have to do with the current working dierctory of the running process? See getcwd() C library function.
    Have you checked the return codes from fopen()?

    Just so we are clear, you are using a non-Qt IDE to write unspecified non-Qt, generic C code, compiled with an unspecified compiler for Windows. That is why we are asking what this has to do with Qt.

Similar Threads

  1. Replies: 1
    Last Post: 7th March 2012, 21:34
  2. Replies: 1
    Last Post: 25th December 2009, 19:43
  3. Replies: 1
    Last Post: 2nd November 2009, 12:02
  4. Replies: 9
    Last Post: 15th April 2009, 06:23
  5. Replies: 8
    Last Post: 10th October 2007, 18:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.