What settings prevent AllocConsole from being included? - windows

I've created a new windows universal dll project in VS2015. I'm trying to use AllocConsole() to create a console window, but I'm getting the errors
error C3861: 'FreeConsole': identifier not found
error C3861: 'AllocConsole': identifier not found
error C2065: 'FILE': undeclared identifier
error C2065: 'stream': undeclared identifier
error C2065: 'stream': undeclared identifier
error C2065: 'stdout': undeclared identifier
error C3861: 'freopen_s': identifier not found
This is after including windows.h, and wincon.h, and consoleapi.h (not sure what this is, F12 took me to it)
I'm guessing it's a project setting that's preventing this from working?

Related

Visual Studio error when ITK and VTK is used

I am doing a project in visual studio 2015When i included ITK and compiled everything ,some errors are occurring
Error C3861 '_beginthreadex': identifier not found
Error C2039 '_time64': is not a member of '`global namespace''
Error C3861 '_time64': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_gmtime64_s': identifier not found
Error C3861 '_localtime64_s': identifier not found
Error C3861 '_mktime64': identifier not found
Error C3861 '_localtime64_s': identifier not found
Error C3861 '_gmtime64_s': identifier not found
Error C2039 '_time64': is not a member of '`global namespace''
Error C3861 '_time64': identifier not found
Error C3646 'm_nLastAnimTime': unknown override specifier
Error C4430 missing type specifier - int assumed. Note: C++ does not
support default-int
Error C3646 'm_ActiveTime': unknown override specifier
Error C4430 missing type specifier - int assumed. Note: C++ does not
support default-int
Error C3646 'm_clkLastTime': unknown override specifier
But i tried including Visual studio/VC/Include and Visual Studio/VC/bin to the Additional Include Directories,still it is showing the same errors.
I also tried changing the Use of MFC and c++ ->code generation ->Runtime Library in configuration properties as well.
I referred this link also,but my problem is not solved.
So i thought may be because of vs2015 instalation problems and tried to build a new project using VTK and ITK in Visualstudio 2017,In there also the same errors are occurring.I have been stuck for weeks ,Can anyone give a solution for my problem?
Are you using this procedure to build ITK and VTK? Are you following this guide to build your own application? Using CMake is the only supported way of using ITK and/or VTK.
If you cannot use CMake, a workaround is to build a hello world example using CMake and then copy include paths and list of libraries to your main Visual Studio application.

What header to include for an NTSTATUS when building for ARM platforms?

I'm working under the VS2013 ARM Developer Prompt. I'm trying to use Microsoft's Cryptography Next Generation (CNG), but I'm experiencing some non-trivial problems.
I'm trying to compile a simple test program:
#include <windows.h>
#include <bcrypt.h>
int main(int argc, char* argv[])
{
BCRYPT_ALG_HANDLE hProvider = NULL;
NTSTATUS ret = BCryptOpenAlgorithmProvider(&hProvider, BCRYPT_RNG_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
if (!(BCRYPT_SUCCESS(ret)))
{
return -1;
}
unsigned char buffer[20];
ret = BCryptGenRandom(hProvider, buffer, (ULONG)sizeof(buffer), 0);
if (!(BCRYPT_SUCCESS(ret)))
{
return -2;
}
ret = BCryptCloseAlgorithmProvider(hProvider, 0);
if (!(BCRYPT_SUCCESS(ret)))
{
return -3;
}
return 0;
}
I attempt to compile it with:
C:\Users\Test>cl.exe /nologo /W4 /D_MBCS /Zi /TP /EHs c /MD /FI sdkddkver.h /FI winapifamily.h /DWINAPI_FAMILY=WINAPI_FAMILY_APP /c test.cxx
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for ARM
Copyright (C) Microsoft Corporation. All rights reserved.
test.cxx
test.cxx(6) : error C2065: 'BCRYPT_ALG_HANDLE' : undeclared identifier
test.cxx(6) : error C2146: syntax error : missing ';' before identifier 'hProvid
er'
test.cxx(6) : error C2065: 'hProvider' : undeclared identifier
test.cxx(7) : error C2065: 'NTSTATUS' : undeclared identifier
test.cxx(7) : error C2146: syntax error : missing ';' before identifier 'ret'
test.cxx(7) : error C2065: 'ret' : undeclared identifier
test.cxx(7) : error C2065: 'hProvider' : undeclared identifier
test.cxx(7) : error C2065: 'BCRYPT_RNG_ALGORITHM' : undeclared identifier
test.cxx(7) : error C2065: 'MS_PRIMITIVE_PROVIDER' : undeclared identifier
test.cxx(7) : error C3861: 'BCryptOpenAlgorithmProvider': identifier not found
test.cxx(8) : error C2065: 'ret' : undeclared identifier
test.cxx(8) : error C3861: 'BCRYPT_SUCCESS': identifier not found
test.cxx(14) : error C2065: 'ret' : undeclared identifier
test.cxx(14) : error C2065: 'hProvider' : undeclared identifier
test.cxx(14) : error C3861: 'BCryptGenRandom': identifier not found
test.cxx(15) : error C2065: 'ret' : undeclared identifier
test.cxx(15) : error C3861: 'BCRYPT_SUCCESS': identifier not found
test.cxx(20) : error C2065: 'ret' : undeclared identifier
test.cxx(20) : error C2065: 'hProvider' : undeclared identifier
test.cxx(20) : error C3861: 'BCryptCloseAlgorithmProvider': identifier not found
test.cxx(21) : error C2065: 'ret' : undeclared identifier
test.cxx(21) : error C3861: 'BCRYPT_SUCCESS': identifier not found
When I attempt to include <ntstatus.h> (scrapped from PJ Naughter's blog because I can't seem to find anything useful from Microsoft):
cl.exe /nologo /W4 /D_MBCS /Zi /TP /EHsc /MD /FI sdkddkver.h /FI winapifamily.h /DWINAPI_FAMILY=WINAPI_FAMILY_APP /c osrng.cpp
osrng.cpp
C:\Program Files (x86)\Windows Kits\8.1\include\shared\ntstatus.h(66) : warning
C4005: 'STATUS_WAIT_0' : macro redefinition
C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(2202) : see p
revious definition of 'STATUS_WAIT_0'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\ntstatus.h(212) : warning
C4005: 'STATUS_ABANDONED_WAIT_0' : macro redefinition
C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(2203) : see p
revious definition of 'STATUS_ABANDONED_WAIT_0'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\ntstatus.h(235) : warning
C4005: 'STATUS_USER_APC' : macro redefinition
...
I can't make it a LONG because Microsoft macros like BCRYPT_SUCCESS cast it to a NTSTATUS code.
I can also duplicate the missing NTSTATUS problem under VS2012 ARM Developer Prompt.
What header file should I include to get a declaration for NTSTATUS under ARM?
I think this might be related, but I'm not certain: fatal error LNK1104: cannot open file 'bcrypt.lib' when building for Surface RT tablet. About all I know is this stuff does not appear to be well tested by Microsoft because there are too many damn problems trying to use it.
The main issue is that BCRYPT is supported for the Universal Windows Platform apps (aka Windows 10 Store apps), but was not supported for Windows 8.x Store apps. VS 2013 toolset always uses the Windows 8.1 SDK so you were building a Windows 8.1 Store app. When you tried VS 2012, you were using the Windows 8.0 SDK so you were building a Windows 8.0 Store apps. Again, neither of this support BCRYPT. If you build with VS 2015 and have the Windows 10 SDK installed, then your code builds fine.
Note that /D_MBCS is not an option for Windows Store apps. All Windows Store apps should be built for Unicode /DUNICODE /D_UNICODE and not ANSI/Multibyte as you were trying to do.
Also, be sure to link with windowsapp.lib to make sure you pick up the correct DLLs when you link.
You can easily confirm that all the errors you are seeing happen in VS 2012/2013 if you do not have #include <bcrypt.h> in the file at all. The DWINAPI_FAMILY=WINAPI_FAMILY_APP ensures that all unsupported APIs are undefined, so with Windows 8.x Store that header was basically an empty file.

Build boost asio 1.58 for windows phone 8.1 & windows 8.1

I had try to build Boost Asio 1.58 for Windows Phone 8.1 & Windows 8.1 with that command b2
b2 toolset=msvc=12.0 windows-api=store architecture=arm
but it's fail on build "libboost_regex-vc120-mt-1_58.lib", so i must need "libboost_regex-vc120-mt-1_58.lib" .
The log say error!
libs\regex\build..\src\fileiter.cpp(102) : error C3861: 'CreateFileA': identifier not found
libs\regex\build..\src\fileiter.cpp(106) : error C3861: 'CreateFileMapping': identifier not found
libs\regex\build..\src\fileiter.cpp(115) : error C3861: 'MapViewOfFile': identifier not found
libs\regex\build..\src\fileiter.cpp(124) : error C3861: 'GetFileSize': identifier not found
libs\regex\build..\src\fileiter.cpp(141) : error C3861: 'UnmapViewOfFile': identifier not found
libs\regex\build..\src\fileiter.cpp(383) : error C3861: 'FindFirstFileA': identifier not found
So anyone can help me fix it ? Thanks :)
Go to C++ -> Preprocessor -> Add "BOOST_REGEX_NO_LIB" for disable auto linking Boost.Regex

opencv running tutorial test undeclared indentifier

I have been trying to install opencv from source for a while now on i have been using the tutorials from
http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html
I got as far a attempting to build the opencv test project in visual studio (i have built it in x86 but i have windows 7 (x64) dont really think it is related to the problem but just in case someone asks).
Now i build the project and I get the following errors:
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(64): error C2065: 'CV_CAP_PROP_FRAME_WIDTH' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(65): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(66): error C2065: 'CV_CAP_PROP_FRAME_WIDTH' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(67): error C2065: 'CV_CAP_PROP_FRAME_HEIGHT' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(79): error C2065: 'CV_WINDOW_AUTOSIZE' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(80): error C2065: 'CV_WINDOW_AUTOSIZE' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(81): error C3861: 'cvMoveWindow': identifier not found
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(82): error C3861: 'cvMoveWindow': identifier not found
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(85): error C2065: 'CV_CAP_PROP_FRAME_COUNT' : undeclared identifier
1>l:\documents\researchproject\opencv_workspace\projects\example1\example1\test.cpp(129): error C3861: 'cvWaitKey': identifier not found
However when i can follow the declaration of highgui.hpp in visual to the file that contains CV_CAP_PROP_FRAME_WIDTH (which for some reason is opencv2/highgui.hpp not opencv2/highgui/highgui.hpp but the latter references the first).
Can anyone explain to why visual studio is not finding the these identifiers?
I have read the link several times and i think i have done everything in there, i would appreciate any help as this is cracking me up.
EDIT AND SOLVED:
Right feel a bit dumb right now, but i will leave this here to others that might find this issue when compiling from github opencv and following the tutorials, the previous issue occurs because changes have occurred in from the version in the website and the one in github, please use the source code version in github (at the time of writing 2.4.9)
https://github.com/Itseez/opencv/blob/master/samples/cpp/tutorial_code/introduction/windows_visual_studio_Opencv/Test.cpp
In this version the CV and cv prefix from enums and methods has disappeared.
I hope this helps and sorry for putting the question and replying to it after, but i did spent a while looking at it.

Connecting DB2 from Node.js on Windows-platform

I am currently mirroring the DB2 to local MySQL-db with some jdbc-code. I would like to connect DB2 directly from Node.js app without having to query the mirror. I am running on Windows and I cannot change to Linux. It seems that work on DB2 with Node.js is yet very marginal or node-odbc is used (unixODBC bindings for node).
I found this project https://github.com/herzi/db2.js which provides DB2-bindings for Node but I cannot install it as the install fails. The package requires Node-gyp (installed this successfully) and .NET framework SDK. I set the vcbuild.exe into my PATH. After these the msbuild.exe complained about missing header files (sqlcli1.h, sqlsystm.h, sqlca.h), which I found out are part of PRO*C.
I took the header files above from here: http://files.edin.dk/php/win32/dev/php_build/include/db2/ and put them into my Node's src/ directory. Now the compiler shows multiple errors.
Are there any other options when working with Windows to connect DB2 from Node.js app than try to get the above module to work?
Anyone able to help me out here? What are the steps to get the above module installed?
Thanks!
Errors shown:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C2146 : syntax error : missing ';' before identifier 'SQLSTATE' [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C2146: syntax error : missing ';' before identifier 'SQLSTATE' [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Documents and Settings\tpaleniu\.node-gyp\0.8.12\src\sqlcli1.h(1501): error C2371: 'SQLTCHAR' : redefinition; different basic types [C:\IS\node\node_modules\db2\build\db2.vcxproj]
C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sqlext.h(30) : see declaration of 'SQLTCHAR'
..\src\connection.cc(77): error C3861: 'snprintf': identifier not found
[C:\IS\node\node_modules\db2\build\db2.vcxproj]..\src\connection.cc(80): error C3861: 'snprintf': identifier not found [C:\IS\node\node_modules\db2\build\db2.vcxproj]
..\src\connection.cc(111): error C3861: 'bzero': identifier not found [C:\IS\node\node_modules\db2\build\db2.vcxproj]
..\src\connection.cc(208): error C3861: 'bzero': identifier not found [C:\IS\node\node_modules\db2\build\db2.vcxproj]
..\src\connection.cc(547): error C2057: expected constant expression [C:\IS\node\node_modules\db2\build\db2.vcxproj]
..\src\connection.cc(547): error C2466: cannot allocate an array of constant size 0 [C:\IS\node\node_modules\db2\build\db2.vcxproj]
..\src\connection.cc(547): error C2133: 'argv' : unknown size [C:\IS\node\node_modules\db2\build\db2.vcxproj]
It is true that node-odbc currently is currently meant only for use with unixODBC. But Daniel VerWeire is currently working on supporting node-odbc on Windows. I guess you need to wait a little while.
Praveen will have a post on it here as soon as it is available

Resources