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 Updated to NodeBB v4.3 + New Features

Issue with testing librairies

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 2 Posters 2.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.
  • S Offline
    S Offline
    soufsouf
    wrote on 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]

    jsulmJ 1 Reply Last reply
    0
    • S soufsouf

      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]

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      2
      • jsulmJ jsulm

        @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 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.

        jsulmJ 1 Reply Last reply
        0
        • S soufsouf

          @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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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 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();
            }

            jsulmJ 1 Reply Last reply
            0
            • S soufsouf

              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();
              }

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on 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 last edited by
                #7

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

                jsulmJ 1 Reply Last reply
                0
                • S soufsouf

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @soufsouf IntToStr not StrToInt

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

                  S 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @soufsouf IntToStr not StrToInt

                    S Offline
                    S Offline
                    soufsouf
                    wrote on 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;

                    }

                    jsulmJ 1 Reply Last reply
                    0
                    • S soufsouf

                      @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;

                      }

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 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
                      0
                      • jsulmJ jsulm

                        @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 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 :/

                        jsulmJ 1 Reply Last reply
                        0
                        • S soufsouf

                          @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 :/

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 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
                          0
                          • jsulmJ jsulm

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

                            S Offline
                            S Offline
                            soufsouf
                            wrote on 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.

                            jsulmJ 1 Reply Last reply
                            0
                            • S soufsouf

                              @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.

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 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
                              0
                              • jsulmJ jsulm

                                @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 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

                                • Login

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