Integrating Tcl into a Qt app on Windows
-
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. -
Hi and welcome to devnet,
What Qt package did you install ?
-
@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,
-
I meant which one did you install ? MinGW, MSVC20XX ?
-
@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.... -
@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.