error: C2065: 'QTcpSocket' : undeclared identifier - c++

I use Qt creator 5.10 in windows 7.
When I build my project error occurs:
error: C2065: 'QTcpSocket' : undeclared identifier
error: C2065: 'QTcpclient' : undeclared identifier
QTcpSocket *tcpClient;
tcpClient = new QTcpSocket(this);

In your .pro file add QT += network and make sure to #include <QTcpSocket>.

Related

#include <Dbghelp.h> doesn't include the header

If you include #include <Dbghelp.h> in, for example, a console C++ application, it will not bring any definitions from the header file and there are more or less similar compiler errors as if this header is not included at all.
Compiler errors looks like:
1>------ Build started: Project: ConsoleDump, Configuration: Debug Win32 ------
1> ConsoleDump.cpp
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2146: syntax error: missing ';' before identifier 'Flags'
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'Flags': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(23): error C2065: 'MiniDumpWithFullMemory': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(24): error C2065: 'MiniDumpWithFullMemoryInfo': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(25): error C2065: 'MiniDumpWithHandleData': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(26): error C2065: 'MiniDumpWithUnloadedModules': undeclared identifier
1>e:\projects\vs2015 projects\consoledump\consoledump\consoledump.cpp(27): error C2065: 'MiniDumpWithThreadInfo': undeclared identifier
What's going wrong?
You must included <windows.h> before <DbgHelp.h>, and if the project uses "Stdafx.h", it must be included before everything else. The following is the correct order:
#include "stdafx.h"
#include <windows.h>
#include <Dbghelp.h>
Also make sure to link DbgHelp.lib to 'Project settings' > Linker > Input > 'Additional Dependencies'.

QtCreator error with undeclared identifier 'Q_NULLPTR'

This is an example of an error that I had when I tried to compile a very simple code.
The code works in Windows, but not in my Mac.
../../../../Qt5.8.0/5.8/clang_64/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:103:65:
error: use of undeclared identifier
'Q_NULLPTR'
../../../../Qt5.8.0/5.8/clang_64/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:135:63:
error: use of undeclared identifier
'Q_RELOCATABLE_TYPE';
and there are more of errors like this.

Visual Studio Community 2015 MFC empty project doesn't compile

I just installed Visual Studio Community 2015 (version 14.0.24720.00) and tried to create an MFC dialog based project.
In the wizard I only selected "Dialog based", leaving all the other settings to default.
The project simply doesn't compile, which isn't exactly a promising starting point...
Am I overlooking something? Is the MFC template broken?
Below, the compile time errors I get (I cut away the long paths for the sake of legibility).
Thanks for your time.
program files (x86)\microsoft visual studio 14.01>------ Build started: Project: MFCApplication, Configuration: Debug Win32 ------
1> stdafx.cpp
1>c:\[...omissis...]\atlcore.h(639): error C2065: 'LOAD_LIBRARY_SEARCH_SYSTEM32': undeclared identifier
1>c:\[...omissis...]\uianimation.h(2621): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxanimationhelper.h(411): error C2065: 'UI_E_VALUE_NOT_SET': undeclared identifier
1>c:\[...omissis...]\afxanimationhelper.h(441): error C2065: 'UI_E_VALUE_NOT_SET': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2103): error C3646: 'm_pConfigs': unknown override specifier
1>c:\[...omissis...]\afxwin.h(2103): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(2024): error C2065: 'GC_PAN_WITH_GUTTER': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2024): error C2065: 'GC_PAN_WITH_INERTIA': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2088): error C2065: 'GC_ALLGESTURES': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2030): error C2065: 'GID_ZOOM': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2030): error C2065: 'GC_ZOOM': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2036): error C2065: 'GID_ROTATE': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2036): error C2065: 'GC_ROTATE': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2042): error C2065: 'GID_TWOFINGERTAP': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2042): error C2065: 'GC_TWOFINGERTAP': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2056): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2056): error C2065: 'GC_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2062): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2062): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_VERTICALLY': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2068): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2068): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2074): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxw
in.h(2074): error C2065: 'GC_PAN_WITH_GUTTER': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2080): error C2065: 'GID_PAN': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2080): error C2065: 'GC_PAN_WITH_INERTIA': undeclared identifier
1>c:\[...omissis...]\afxwin.h(2964): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(2964): error C3646: 'GetCurrentGestureInfo': unknown override specifier
1>c:\[...omissis...]\afxwin.h(2964): error C2059: syntax error: ')'
1>c:\[...omissis...]\afxwin.h(2965): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\[...omissis...]\afxwin.h(3020): error C2061: syntax error: identifier 'PTOUCHINPUT'
1>c:\[...omissis...]\afxwin.h(3030): error C2061: syntax error: identifier 'PTOUCHINPUT'
1>c:\[...omissis...]\afxwin.h(3043): error C3646: 'm_pCurrentGestureInfo': unknown override specifier
1>c:\[...omissis...]\afxwin.h(3043): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(4141): error C2061: syntax error: identifier 'TBPFLAG'
1>c:\[...omissis...]\afxwin.h(5447): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxwin.h(5447): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxwin.h(5447): error C2238: unexpected token(s) preceding ';'
1>c:\[...omissis...]\afxglobals.h(315): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxglobals.h(315): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxglobals.h(315): error C2238: unexpected token(s) preceding ';'
1>c:\[...omissis...]\afxadv.h(244): error C2143: syntax error: missing ';' before '*'
1>c:\[...omissis...]\afxadv.h(244): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\[...omissis...]\afxadv.h(245): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\[...omissis...]\afxadv.h(314): error C2061: syntax error: identifier 'KNOWNDESTCATEGORY'
1>c:\[...omissis...]\afxadv.h(390): error C2065: 'ICustomDestinationList': undeclared identifier
1>c:\[...omissis...]\afxadv.h(390): error C2923: 'ATL::CComPtr': 'ICustomDestinationList' is not a valid template type argument for parameter 'T'
1>c:\[...omissis...]\afxadv.h(273): error C2039: 'AbortList': is not a member of 'ATL::_NoAddRefReleaseOnCComPtr<T>'
1>c:\[...omissis...]\afxadv.h(428): error C2065: 'IApplicationDestinations': undeclared identifier
1>c:\[...omissis...]\afxadv.h(428): error C2923: 'ATL::CComPtr': 'IApplicationDestinations' is not a valid template type argument for parameter 'T'
1>c:\[...omissis...]\afxadv.h(430): warning C4624: 'CAppDestinations': destructor was implicitly defined as deleted
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Solved.
Visual studio 2015 inherited the Visual Studio 2009 settings.
Removing the include folder
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
everything started to work normally
Had a similar problem bringing 2010 forward to 2015. Tracked the problem down to the targetver.h file. It was defining older versions of windows. Replaced all previous defines with the current default.
target.h
// delete everything here
#include <SDKDDKVer.h>
-- end of target.h
Maybe this can help you to fix your problem.
In Visual Studio 2015, C++ tooling is no longer installed by default. Instead, the C++ compiler, libraries, and project templates have been moved into an optional feature. Upon launching setup, you can choose a “Typical” or “Custom” install;
If you choose “Typical”, then you can’t use Visual Studio to develop in C++, because only managed languages and web development tools will be installed.
Setup Changes in Visual Studio 2015 Affecting C++ Developers

RPC_CSTR' : undeclared identifier while compile c++ using Nmake

I use rpcrt4.lib to generate dll. While generate dll using nmake ( cl.exe compiler) in Visual studio 2003 .Net, getting following error
nstaller\UUIDGenerator.cpp(35) : error C2065: 'RPC_CSTR' : undeclared identifier
installer\UUIDGenerator.cpp(35) : error C2059: syntax error : ')'
installer\UUIDGenerator.cpp(68) : error C2059: syntax error : ')'
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Cause :
I use following function
UuidToStringA(&uuid, (RPC_CSTR*)&str);
You need to link to rpcrt4.lib, which it sounds like you did.
But you also need to:
#include "Rpcdce.h"
This error
error C2065: 'RPC_CSTR' : undeclared identifier
Means that it doesn't know if this is a class, variable name, etc. That's why it needs the header file.

Compile error external interface Simulink

I get the compiler error when I attempt to compile a Simulink model to C/C++ code with a external interface:
ert_main.cpp(118) : error C3861: 'rtSetTFinalForExtMode': identifier not found
ert_main.cpp(129) : error C3861: 'rtERTExtModeStartMsg': identifier not found
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
The make command returned an error of 2
The model compiles without errors if the interface is set to "none".
I am using Matlab 2013a (Simulink 8.1). The compiler used is Microsoft Visual 2010 Professional.
The issue has been resolved. For people who are facing the same problem:
- The Siemens WinAC (example) documentation only uses Matlab2012b, consider compiling your model on the 2012b version of Matlab when you're using a different version;
In the Matlab Workspace cd your way to C:\Program Files\Siemens\WinAC\WinAC Target\WinAC Target Files and run the startup.m -file;
DO NOT change the current searchpath location;
DO NOT paste any other source files to this location otherwise you confuse the compiler wich file to take;
In my case I got the following errors:
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(343) : error C2065: 'ODK_YEAR_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(343) : error C2065: 'ODK_YEAR_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(346) : error C2065: 'ODK_MON_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(346) : error C2065: 'ODK_MON_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(349) : error C2065: 'ODK_DAY_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(349) : error C2065: 'ODK_DAY_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(352) : error C2065: 'ODK_HOUR_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(352) : error C2065: 'ODK_HOUR_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(355) : error C2065: 'ODK_MIN_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(355) : error C2065: 'ODK_MIN_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(358) : error C2065: 'ODK_SEC_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(358) : error C2065: 'ODK_SEC_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(361) : error C2065: 'ODK_MILLI_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(361) : error C2065: 'ODK_MILLI_MIN' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(364) : error C2065: 'ODK_WDAY_MAX' : undeclared identifier
C:\PROGRA~1\Siemens\WinAC\WINACT~1\WINACT~1\src\WinLCReadWriteData.cpp(364) : error C2065: 'ODK_WDAY_MIN' : undeclared identifier
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
To silence this error open the WinLCReadWriteData.cpp -file and comment out lines 343 to 365.
Now it compiles fine, without errors. External mode also works without issues.