C1075 error reading tlh file
-
Hi,
I am trying to access a c# dll from QT using COM. I am able to do this no problem in C++ in visual studio, when I add the same code to QT i get an error when building:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\comdef.h:56: error: C1075: end of file found before the left brace '{' at 'c:\users\mypath\myfile.tlh(19)' was matched
The generated tlh file using QT (with VC++ Compiler 12) appears identical to the tlh file generated by visual studio and there certainly doesn't appear to be a missing brace.
Unfortunately I am unable to use any compiler other than VC++ Compiler 12 (2013) do to restrictions placed on me by some 3rd party software (Siemens WinCC OA).
The import line is:
#import "C:\Users\mypath\myfile.tlb" raw_interfaces_onlyAny suggestions?
tlh file contents follow:
// Created by Microsoft (R) C/C++ Compiler Version 12.00.40629.0 (e9f66a42). // // c:\users\mypath\myclass.tlh // // C++ source equivalent of Win32 type library C:\Users\mypath\Myclass.tlb // compiler-generated file created 02/11/20 at 10:33:06 - DO NOT EDIT! // // Cross-referenced type libraries: // // #import "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.tlb" // #pragma once #pragma pack(push, 8) #include <comdef.h> namespace MyClass { // // Forward references and typedefs // struct __declspec(uuid("7cd620e2-86e5-4de1-95b8-9319b9d4e4d9")) /* LIBID */ __MyClass; struct /* coclass */ TheClass; struct __declspec(uuid("0e01bd9c-c1c5-3f60-9ae2-fd5ddfcdb7ae")) /* dual interface */ _TheClass; // // Smart pointer typedef declarations // _COM_SMARTPTR_TYPEDEF(_TheClass, __uuidof(_TheClass)); // // Type library items // struct __declspec(uuid("7dee8be0-f9db-4c27-b407-463a9d67aea6")) TheClass; // [ default ] interface _TheClass // interface _Object struct __declspec(uuid("0e01bd9c-c1c5-3f60-9ae2-fd5ddfcdb7ae")) _TheClass : IDispatch { // // Raw methods provided by interface // virtual HRESULT __stdcall get_ToString ( /*[out,retval]*/ BSTR * pRetVal ) = 0; virtual HRESULT __stdcall Equals ( /*[in]*/ VARIANT obj, /*[out,retval]*/ VARIANT_BOOL * pRetVal ) = 0; virtual HRESULT __stdcall GetHashCode ( /*[out,retval]*/ long * pRetVal ) = 0; virtual HRESULT __stdcall GetType ( /*[out,retval]*/ struct _Type * * pRetVal ) = 0; virtual HRESULT __stdcall GetTheThing ( /*[in]*/ BSTR arg, /*[out,retval]*/ BSTR * pRetVal ) = 0; }; } // namespace MyClass #pragma pack(pop)
-
Hi @Mike10,
it should not matter if you use the same MSVC compiler from within Visual Studio or Qt Creator, as long as the compiler options are equal. Do note that
qmake
does set some options by default (likeUNICODE
) that might lead to different results than in Visual Studio.So can you show your
.pro
file and the compiler call from Compile Output that leads to the given error message?Regards
-
Hi,
Thanks for the reply.
Pro file contents:
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = csharp_import TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui
cpp file:
#include "mainwindow.h" #include "ui_mainwindow.h" #import "C:\Users\mypath\Myclass.tlb" raw_interfaces_only MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { CoInitialize(0); // Init COM BSTR thing_to_send = ::SysAllocString(L"My thing, or ... "); BSTR returned_thing; MyClass::_TheClassPtr obj(__uuidof(MyClass::TheClass)); HRESULT hResult = obj->GetTheThing(thing_to_send, &returned_thing); ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; }
Compiler output:
11:13:15: Configuration unchanged, skipping qmake step. 11:13:15: Starting: "C:\Qt\Qt5.5.1\Tools\QtCreator\bin\jom.exe" C:\Qt\Qt5.5.1\Tools\QtCreator\bin\jom.exe -f Makefile.Debug cl -c -nologo -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\csharp_import.pdb -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQ_BYTE_ORDER=Q_LITTLE_ENDIAN -DQT_NO_PRINTER -DQT_NO_PRINTDIALOG -DWINAPI_FAMILY=WINAPI_FAMILY_APP -DX64 -D__X64__ -D__x64__ -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I..\csharp_import -I. -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\include -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\include\QtWidgets -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\include\QtGui -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\include\QtANGLE -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\include\QtCore -Idebug -I. -I..\..\..\..\Qt\Qt5.5.1\5.5\winrt_x64\mkspecs\winrt-x64-msvc2013 -Fodebug\ @C:\Users\mypath\AppData\Local\Temp\mainwindow.obj.16568.0.jom mainwindow.cpp C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\comdef.h(56) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\mypath\build-csharp_import-qt_5_5_1_for_windows_runtime_64bit-debug\debug\myclass.tlh(19)' was matched jom: C:\Users\mypath\build-csharp_import-Qt_5_5_1_for_Windows_Runtime_64bit-Debug\Makefile.Debug [debug\mainwindow.obj] Error 2 jom: C:\Users\mypath\build-csharp_import-Qt_5_5_1_for_Windows_Runtime_64bit-Debug\Makefile [debug] Error 2 11:13:17: The process "C:\Qt\Qt5.5.1\Tools\QtCreator\bin\jom.exe" exited with code 2. Error while building/deploying project csharp_import (kit: Qt 5.5.1 for Windows Runtime 64bit) When executing step "Make" 11:13:17: Elapsed time: 00:02.
-
The kits I have are:
Qt 5.5.1 for windows phone arm MSVC2013 32bit
Qt 5.5.1 for windows phone x86 MSVC2013 32bit (Emulator)
Qt 5.5.1 for windows runtime 64bitSo I chose the last of those.
I actually want to make a dll for integration with WinCC OA that will also link to a C# library. The first part of this works and I can build a dll that works as a WinCC OA plugin, I am struggling with the 2nd part so created a new project with same settings as the working WinCC OA project.
-
Unfortunately WinCC OA 3.15 requires no later than QT 5.5.1, MSVC 2013 and Win 64bit
I have downloaded a different file from https://download.qt.io/archive/qt/5.5/5.5.1/ and that does indeed seem to have resolved the compilation issue :)
I am now getting an error at runtime but could be something daft so I will look into more.
Thanks