Compile using CL.exe with different toolset
Just incase someone need it, i was able to solve this isuue. i added this option to cl.exe:
/D \"_USING_V110_SDK71_\"
And also i modified this option:
/SUBSYSTEM:WINDOWS
to
/SUBSYSTEM:WINDOWS,5.01
After the application runs succesfully on windows xp. You might encounter some problems if you are heavily useing crt in your exe, in my exe i only needed CRT to define Tls callbacks, they do not work without CRT, so i guess maybe this is why this worked for me
How to enable unicode when compiling using cl.exe from Visual Studio Build Tools?
Like @Hans Passant stated it the comment, problem was that compiler doesn't recognize my source file as unicode. Saving a file with BOM or adding /source-charset:utf-8
option makes it work correctly. I prefer the second option: cl /source-charset:utf-8 C:\path_to_source\preventShutdown.c kernel32.lib user32.lib /DUNICODE /D_UNICODE /O2 /link /NODEFAULTLIB /ENTRY:wWinMain
How to compile x64 code with Visual Studio in command line?
You need to use a version of the cl.exe compiler which emits x64 code. Which one depends a bit on your setup.
Let's consider the case you're on a 64 bit machine. For this you'll need to use the compiler which lives at
c:\Program Files (x86)\Microsoft visual Studio 10.0\VC\bin\amd64\cl.exe
If you're on a 32 bit machine you'll need to use the cross compiler located at
c:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\cl.exe
Related Topics
C++ Object Instantiation VS Assignment
Portability of Native C++ Properties
Brute-Force, Single-Threaded Prime Factorization
Why Don't I Need to Specify "Typename" Before a Dependent Type in C++20
How to Test If a Constexpr Function Is Evaluated at Compile Time
Macro to Replace C++ Operator New
Clean Up Your #Include Statements
Initialize Std::Array with a Range (Pair of Iterators)
Google Protocol Buffers on iOS
Recognize Open and Closed Shapes Opencv
Is C++ Considered Weakly Typed? Why
Does Std::Array<> Guarantee Allocation on the Stack Only
Can Templates Be Used to Access Struct Variables by Name
Sfinae and Partial Class Template Specializations
Automatically Generate C++ File from Header
Direct Boost Serialization to Char Array
Find Four Elements in Array Whose Sum Equal to a Given Number X