Results 1 to 6 of 6

Thread: DEBUG version working, release version is not compiling

  1. #1
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default DEBUG version working, release version is not compiling

    Hello,
    First of all:
    I got my code in debug mode compiled, but the compiler says sometimes that one of my functions is defined multiple times with a hint where it is defined for the first time. I checked the code but it is only defined there and thats it. The multiple definition error points me to a moc_ file where the function definition is. So I deleted this code and compiled it a second time and it worked.

    Now in release mode:
    When i compile it in release mode i get the same errors of multiple definitions. When i click the first defined here error it points me to the code where the functions is defined, as expected. But when I click the multiple definition error, it says that the moc_ file is not found.

    Here are the three errors I get:
    • multiple defintion of `function name`
    • first defined here
    • collect2: Id returned 1 exit status


    What do I have to do to compile it in release mode?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,393
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: DEBUG version working, release version is not compiling

    The multiple definition error points me to a moc_ file where the function definition is. So I deleted this code and compiled it a second time and it worked.
    You deleted something in moc_ file ? This is not a good solution, you should correct your code instead. Maybe you are trying to provide implementation for a signal ?
    It'll be easier to help if you show the actual errors and some relevant code.

  3. #3
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DEBUG version working, release version is not compiling

    Okay, here is the code (I shrinked it down cause it would be too much otherwise):

    The error has to do with the options box
    Qt Code:
    1. //OptionsDialog.h
    2. class C_OptionsDialog : public QDialog
    3. {
    4. Q_OBJECT
    5. public:
    6. //...
    7.  
    8. public slots:
    9. //...
    10.  
    11. signals:
    12. void setSmoothingGrp(int lvl);
    13.  
    14. private:
    15. //... widget elements
    16. }
    To copy to clipboard, switch view to plain text mode 

    In the constructor i connected the setSmoothingGrp signal like this (same file after the constructor):
    Qt Code:
    1. connect(sigMapper, SIGNAL(mapped(int)), this, SIGNAL(setSmoothingGrp(int)));
    To copy to clipboard, switch view to plain text mode 
    but i also declared the setSmoothingGrp function like this:
    Qt Code:
    1. void C_OptionsDialog::setSmoothingGrp(int lvl)
    2. {
    3. smoothingLevel = lvl;
    4. currentLab->setText(QString("Current %1").arg(smoothingLevel));
    5. currentLab->update();
    6. }
    To copy to clipboard, switch view to plain text mode 

    I think the error occurs because of one time defined as a signal and one time seen as a function

    when i change the OptionsDialog.h like this, Qt Creator compiles the files fine:
    Qt Code:
    1. class C_OptionsDialog : public QDialog
    2. {
    3. Q_OBJECT
    4. public:
    5. //...
    6.  
    7. public slots:
    8. //...
    9.  
    10. //signals:
    11. //setSmoothingGrp(int lvl);
    12.  
    13. private:
    14. void setSmoothingGrp(int lvl);
    15. //... widget elements
    16. }
    To copy to clipboard, switch view to plain text mode 

    But when i now click one of the buttons nothing happens, the setSmoothing function gets not been executed.

  4. #4
    Join Date
    Jun 2011
    Location
    Chennai, India
    Posts
    30
    Thanks
    13
    Thanked 6 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DEBUG version working, release version is not compiling

    1. Do not edit the moc_XXX.h files
    2. You only need to declare the signals(in the .h file) . You do not (and should not) provide an implementation for it (in the .cpp file). Qt generates the code for signals by itself.

    If you remove the function definition in the .cpp file and keep the declaration in the .h file, things should be fine.

  5. #5
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: DEBUG version working, release version is not compiling

    The first time you have a signal and a slot with the same name why? Don't do that.

    Then once you removed the signal , nothing will happen when you click because you forgot to declare setSmoothingGrp(int) as slots. Try
    Qt Code:
    1. private slots:
    2. void setSmoothingGrp(int lvl);
    To copy to clipboard, switch view to plain text mode 

    I am very surprised your compile fine in debug mode.

  6. The following user says thank you to nix for this useful post:

    seux (26th August 2011)

  7. #6
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DEBUG version working, release version is not compiling

    @gkarthick5:
    When i remove the definition from the cpp file it compiles fine, yeah, but then nothing happens when i click one of the buttons, which makes sense.

    Many thanks for your help, I got it working now, nix post pointed me in the right direction

    But there is a last question i have( I am sure that it was asked already, but i don't really know keywords to make the search useful):
    I have got my final release version as an exe file, but it still needs some .dll files to run. Is it possible to make it work without the .dll files, so that it is just the exe file. I am using qt version 4.7.3 and Qt Creator 2.1.0. Do i need something special for this and how difficult is it? If there is already a thread or a site in the Qt documentation, can you just give me the link?

Similar Threads

  1. builing a release version
    By GrahamLabdon in forum Newbie
    Replies: 0
    Last Post: 21st October 2010, 11:04
  2. Replies: 0
    Last Post: 11th August 2009, 09:38
  3. Replies: 5
    Last Post: 5th October 2008, 05:12
  4. Replies: 6
    Last Post: 10th November 2006, 10:38
  5. Problem with Release version
    By jlbrd in forum Installation and Deployment
    Replies: 7
    Last Post: 30th March 2006, 19:45

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.