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. Integrating Tcl into a Qt app on Windows
Forum Updated to NodeBB v4.3 + New Features

Integrating Tcl into a Qt app on Windows

Scheduled Pinned Locked Moved General and Desktop
tclwindows 7qt5.5
8 Posts 3 Posters 4.0k Views 2 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.
  • A Offline
    A Offline
    Algae
    wrote on last edited by
    #1

    I'm trying to create an app that has a Tcl-command line interface like the QTclConsole but can't seem to get things to link. I'm running Qt5.5 on Windows 7 with cygwin64. If I create a plain vanilla program outside of Qt and call Tcl_Main, it works as expected.

    #include <tcl.h>
    
    int tclAppInit(Tcl_Interp *anInterp)
    {
    	return(0);
    }
    
    int main(int argc,
    				 char *argv[])
    {
    	Tcl_Main(argc,
    					 argv,
    					 tclAppInit);
    	return(0);
    }
    

    But, if I try the same vanilla code in Qt, I need to change the include a bit to compile like this:

    #include "c:\cygwin64\usr\include\tcl.h"
    
    int tclAppInit(__attribute__ ((unused)) Tcl_Interp *anInterp)
    {
    	return(0);
    }
    
    int main(int argc,
    				 char *argv[])
    {
    	Tcl_Main(argc,
    					 argv,
    					 tclAppInit);
    
    	return(0);
    }
    

    But, I can't seem to get the link phase to work. The closest I've come to getting it to work is by changing the .pro file to look like this:

    QT       += core
    QT       -= gui
    LIBS += -Lc:\cygwin64\lib -ltcl.dll
    TARGET = Test1
    CONFIG   += console
    CONFIG   -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp
    

    But, I get the "File format not recognized" error for libtcl.dll.a. All other variants of -L and -l give me the "File not found" errors.
    The usual Web searches seem to come up empty for this platform.
    I figure I can't be the first one to try this. Does anyone have a working recipe to get tcl in a Qt app on Windows?
    Eventually, I want to add commands to the Tcl interpreter to do new app-specific stuff along with the scripting features of the tcl envrionment.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What Qt package did you install ?

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        What Qt package did you install ?

        A Offline
        A Offline
        Algae
        wrote on last edited by
        #3

        @SGaist
        I've got the open source Qt package installed if that is what you are referring to.

        1 Reply Last reply
        0
        • TheBadgerT Offline
          TheBadgerT Offline
          TheBadger
          wrote on last edited by
          #4

          @Algae said:
          Not sure about the error but a quick comment:

           LIBS += -Lc:\cygwin64\lib -ltcl.dll
          

          Your -L should be the path to the library, that is correct, the issue is that on windows you either need to use double back slash (\\) or forward slash (/), qmake should have warned about that.

          The -l should point to a linker file, not dll. I think on windows it is a .a file. The dll file needs to be in the path when the application runs, the .a file gives the simbols to link with. qmake should handle the extension correctly on the given platform, so just specify -ltcl. (Make sure the -L points to where the .a file is)

          Regards,


          Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

          A 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            I meant which one did you install ? MinGW, MSVC20XX ?

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

            A 1 Reply Last reply
            0
            • TheBadgerT TheBadger

              @Algae said:
              Not sure about the error but a quick comment:

               LIBS += -Lc:\cygwin64\lib -ltcl.dll
              

              Your -L should be the path to the library, that is correct, the issue is that on windows you either need to use double back slash (\\) or forward slash (/), qmake should have warned about that.

              The -l should point to a linker file, not dll. I think on windows it is a .a file. The dll file needs to be in the path when the application runs, the .a file gives the simbols to link with. qmake should handle the extension correctly on the given platform, so just specify -ltcl. (Make sure the -L points to where the .a file is)

              Regards,

              A Offline
              A Offline
              Algae
              wrote on last edited by
              #6

              @TheBadger said:

              on windows you either need to use double back slash (\\) or forward slash (/), qmake should have warned about that.

              I changed it to a / delimiter and it did not notice any difference--still get the link error.

              The -l should point to a linker file, not dll. I think on windows it is a .a file. The dll file needs to be in the path when the application runs, the .a file gives the simbols to link with. qmake should handle the extension correctly on the given platform, so just specify -ltcl. (Make sure the -L points to where the .a file is)

              So I changed it to just "-ltcl" like this:
              LIBS += -Lc:/cygwin64/lib -ltcl
              and I get the same "File format not recognized" error. The file I believe I'm linking to is named libtcl.dll.a. So, it seems I can refer to it either way? Curious....

              TheBadgerT 1 Reply Last reply
              0
              • SGaistS SGaist

                I meant which one did you install ? MinGW, MSVC20XX ?

                A Offline
                A Offline
                Algae
                wrote on last edited by
                #7

                @SGaist said:

                I meant which one did you install ? MinGW, MSVC20XX ?

                MinGW

                1 Reply Last reply
                0
                • A Algae

                  @TheBadger said:

                  on windows you either need to use double back slash (\\) or forward slash (/), qmake should have warned about that.

                  I changed it to a / delimiter and it did not notice any difference--still get the link error.

                  The -l should point to a linker file, not dll. I think on windows it is a .a file. The dll file needs to be in the path when the application runs, the .a file gives the simbols to link with. qmake should handle the extension correctly on the given platform, so just specify -ltcl. (Make sure the -L points to where the .a file is)

                  So I changed it to just "-ltcl" like this:
                  LIBS += -Lc:/cygwin64/lib -ltcl
                  and I get the same "File format not recognized" error. The file I believe I'm linking to is named libtcl.dll.a. So, it seems I can refer to it either way? Curious....

                  TheBadgerT Offline
                  TheBadgerT Offline
                  TheBadger
                  wrote on last edited by
                  #8

                  @Algae said:

                  I changed it to a / delimiter and it did not notice any difference--still get the link error

                  This would not have done anything related to the linker error, just a comment.

                  The file I believe I'm linking to is named libtcl.dll.a

                  Then I suppose it should be tcl.dll. I should have paid more attention, since it says "file format not recognized" it does mean that it finds the file, thus your link command is correct.

                  Might it be that you are trying to compile with 32-bit compiler and link to 64-bit lib?
                  This is just a guess, I see you say you use cygwin 64, just check the architectures.

                  Apart from these comments I don't think I can help, sorry.


                  Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

                  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