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. Issue with testing librairies
Forum Update on Monday, May 27th 2025

Issue with testing librairies

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 2 Posters 2.9k Views
  • 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.
  • S Offline
    S Offline
    soufsouf
    wrote on 20 Jun 2017, 08:52 last edited by kshegunov
    #1

    Hello everyone,

    After creating a librairy i want to test it in an other console application but as soon as i call a fonction from the librairy the result is an empty console where it is only written press <Entry> to close the window...

    I did a small example to test including a librairy and i have no problem doing it.

    Where this issue can come from ?

    Thank you in advance for any help.

    [Moved to General and Desktop ~kshegunov]

    J 1 Reply Last reply 20 Jun 2017, 10:57
    0
    • S soufsouf
      20 Jun 2017, 08:52

      Hello everyone,

      After creating a librairy i want to test it in an other console application but as soon as i call a fonction from the librairy the result is an empty console where it is only written press <Entry> to close the window...

      I did a small example to test including a librairy and i have no problem doing it.

      Where this issue can come from ?

      Thank you in advance for any help.

      [Moved to General and Desktop ~kshegunov]

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 20 Jun 2017, 10:57 last edited by
      #2

      @soufsouf How exactly do you test? It is completely unclear from your description! Does the function from the library which you call print anything?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 20 Jun 2017, 11:38
      2
      • J jsulm
        20 Jun 2017, 10:57

        @soufsouf How exactly do you test? It is completely unclear from your description! Does the function from the library which you call print anything?

        S Offline
        S Offline
        soufsouf
        wrote on 20 Jun 2017, 11:38 last edited by
        #3

        @jsulm

        yes i am printing the result of the fonction called.

        I built a library called Util: libUtil.a where you have for example this fonction :
        int StrToInt(const UtilString& aString)
        {
        int num = aString.toInt();

        if(aString.indexOf(".") != -1)
        {
            num = RoundToInt(aString.toDouble());
        
        }
        return num;
        

        }

        and when i call this function in the main of the test project (in which i included the Library):

        UtilString num1ToStr = IntToStr(num1,true,5);
        std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl;

        i have always the console with nothing on it.

        In an other hand i did a small example with a fonction that print hello and increase the value of an int by +1 and it works just fine.

        thank you in advance for your time.

        J 1 Reply Last reply 20 Jun 2017, 11:43
        0
        • S soufsouf
          20 Jun 2017, 11:38

          @jsulm

          yes i am printing the result of the fonction called.

          I built a library called Util: libUtil.a where you have for example this fonction :
          int StrToInt(const UtilString& aString)
          {
          int num = aString.toInt();

          if(aString.indexOf(".") != -1)
          {
              num = RoundToInt(aString.toDouble());
          
          }
          return num;
          

          }

          and when i call this function in the main of the test project (in which i included the Library):

          UtilString num1ToStr = IntToStr(num1,true,5);
          std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl;

          i have always the console with nothing on it.

          In an other hand i did a small example with a fonction that print hello and increase the value of an int by +1 and it works just fine.

          thank you in advance for your time.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 20 Jun 2017, 11:43 last edited by
          #4

          @soufsouf Try to add std::flush:

          std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl << std::flush;
          

          Also can you show your main function where you call the library function?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • S Offline
            S Offline
            soufsouf
            wrote on 20 Jun 2017, 11:57 last edited by
            #5

            in my main :
            #include "Util.h"
            #include <iostream>
            using namespace std;

            int main(int argc, char *argv[])
            {

            QCoreApplication a(argc, argv);
             int num1=52;
             UtilString chaine1="toto "; //(UtilString is define in my librairy)
             std::cout << "La chaine creee par chaine1= toto  est:" <<chaine1.toStdString() << endl; //this works just fine 
             
               UtilString num1ToStr;
              num1ToStr = IntToStr(num1,true,5); //when  i call IntToStr() nothing works anymore even the beginning
               std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl; 
            

            return a.exec();
            }

            J 1 Reply Last reply 20 Jun 2017, 12:11
            0
            • S soufsouf
              20 Jun 2017, 11:57

              in my main :
              #include "Util.h"
              #include <iostream>
              using namespace std;

              int main(int argc, char *argv[])
              {

              QCoreApplication a(argc, argv);
               int num1=52;
               UtilString chaine1="toto "; //(UtilString is define in my librairy)
               std::cout << "La chaine creee par chaine1= toto  est:" <<chaine1.toStdString() << endl; //this works just fine 
               
                 UtilString num1ToStr;
                num1ToStr = IntToStr(num1,true,5); //when  i call IntToStr() nothing works anymore even the beginning
                 std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl; 
              

              return a.exec();
              }

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 20 Jun 2017, 12:11 last edited by
              #6

              @soufsouf said in Issue with testing librairies:

              when i call IntToStr() nothing works anymore even the beginning

              Can you show content of IntToStr?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                soufsouf
                wrote on 20 Jun 2017, 12:13 last edited by
                #7

                int StrToInt(const UtilString& aString)
                {
                int num = aString.toInt();
                if(aString.indexOf(".") != -1)
                {
                num = RoundToInt(aString.toDouble());
                }
                return num;
                }

                J 1 Reply Last reply 20 Jun 2017, 12:18
                0
                • S soufsouf
                  20 Jun 2017, 12:13

                  int StrToInt(const UtilString& aString)
                  {
                  int num = aString.toInt();
                  if(aString.indexOf(".") != -1)
                  {
                  num = RoundToInt(aString.toDouble());
                  }
                  return num;
                  }

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 20 Jun 2017, 12:18 last edited by
                  #8

                  @soufsouf IntToStr not StrToInt

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply 20 Jun 2017, 12:19
                  0
                  • J jsulm
                    20 Jun 2017, 12:18

                    @soufsouf IntToStr not StrToInt

                    S Offline
                    S Offline
                    soufsouf
                    wrote on 20 Jun 2017, 12:19 last edited by
                    #9

                    @jsulm sorry

                    UtilString IntToStr(int aValue, bool signPart,int integerPart)
                    {
                    UtilString s="";

                    int intpart=abs(aValue);
                    
                    if(signPart) s+=((aValue>=0)?"+":"-");
                    
                    {
                        UtilString ss;
                    
                        if(integerPart>0)
                        {
                            ss = UtilString("%1").arg(intpart,integerPart);
                            ss.replace(' ','0');
                        }
                        else
                        {
                            ss = UtilString("%1").arg(intpart);
                        }
                        s+=ss;
                    }
                    

                    return s;

                    }

                    J 1 Reply Last reply 20 Jun 2017, 12:24
                    0
                    • S soufsouf
                      20 Jun 2017, 12:19

                      @jsulm sorry

                      UtilString IntToStr(int aValue, bool signPart,int integerPart)
                      {
                      UtilString s="";

                      int intpart=abs(aValue);
                      
                      if(signPart) s+=((aValue>=0)?"+":"-");
                      
                      {
                          UtilString ss;
                      
                          if(integerPart>0)
                          {
                              ss = UtilString("%1").arg(intpart,integerPart);
                              ss.replace(' ','0');
                          }
                          else
                          {
                              ss = UtilString("%1").arg(intpart);
                          }
                          s+=ss;
                      }
                      

                      return s;

                      }

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 20 Jun 2017, 12:24 last edited by
                      #10

                      @soufsouf If you comment out everything in IntToStr and just return an empty string, does it work then?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      S 1 Reply Last reply 20 Jun 2017, 12:31
                      0
                      • J jsulm
                        20 Jun 2017, 12:24

                        @soufsouf If you comment out everything in IntToStr and just return an empty string, does it work then?

                        S Offline
                        S Offline
                        soufsouf
                        wrote on 20 Jun 2017, 12:31 last edited by
                        #11

                        @jsulm no i already did it (but i did it again) no problem during the compilation but the execution give an empty console without any error message :/

                        J 1 Reply Last reply 20 Jun 2017, 12:33
                        0
                        • S soufsouf
                          20 Jun 2017, 12:31

                          @jsulm no i already did it (but i did it again) no problem during the compilation but the execution give an empty console without any error message :/

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 20 Jun 2017, 12:33 last edited by
                          #12

                          @soufsouf It could be toStdString() from your UtilString, you should check it

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          S 1 Reply Last reply 20 Jun 2017, 12:50
                          0
                          • J jsulm
                            20 Jun 2017, 12:33

                            @soufsouf It could be toStdString() from your UtilString, you should check it

                            S Offline
                            S Offline
                            soufsouf
                            wrote on 20 Jun 2017, 12:50 last edited by
                            #13

                            @jsulm if i hide this line: std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl; the beginning of the main is not printed in the console because of the IntToStr() call that is why it can't be something related to the printing ! i has been 3 days now that i am dealling with this issue do not know where to search.

                            J 1 Reply Last reply 20 Jun 2017, 12:54
                            0
                            • S soufsouf
                              20 Jun 2017, 12:50

                              @jsulm if i hide this line: std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl; the beginning of the main is not printed in the console because of the IntToStr() call that is why it can't be something related to the printing ! i has been 3 days now that i am dealling with this issue do not know where to search.

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 20 Jun 2017, 12:54 last edited by
                              #14

                              @soufsouf Did you try to debug step-by-step? Put a break point at the first line in IntToStr().

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              S 1 Reply Last reply 20 Jun 2017, 13:30
                              0
                              • J jsulm
                                20 Jun 2017, 12:54

                                @soufsouf Did you try to debug step-by-step? Put a break point at the first line in IntToStr().

                                S Offline
                                S Offline
                                soufsouf
                                wrote on 20 Jun 2017, 13:30 last edited by
                                #15

                                @jsulm I Can not explain why but when you asked me to debug a file in my librairy i changed from release to Debug the compiler of my Library project
                                And then it worked !!!!
                                Since my main.cpp to test the project is in Debug mode also i thought you have to be in the same mode in both ( Library and Test ) but when both are in release mode it doesn't work.

                                Whatever thank you for your indications it'a good step.

                                1 Reply Last reply
                                0

                                1/15

                                20 Jun 2017, 08:52

                                • Login

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