I read on some blogs online you can use int 2Eh or sysenter instead of syscall in an asm file. So I tried both of these but it doesn't work for me to run the program. For int 2Eh, it compiles but program doesn't run and do what it should do(which it does if I use "syscall" instead). And for sysenter, it doesn't even compile because compiler can't recognize the word syscall.
I am using latest Visual Studio and my project is an 64-bit exe file. Anyone have ideas what I can try?
Related
I could successfully build the libssh2 library for windows using Compiling libssh2 on windows. I am not able to figure out the command to compile a simple C program on a windows system that uses libssh2 , say any example code from https://libssh2.org/examples/
My system: Windows Server 2019, Visual studio 2017.
Command I tried:
cl ssh2_exec.c
Error: cannot open include file : 'libssh2.h': no such file or directory
Try and type first:
set INCLUDE=%INCLUDE%;C:\path\to\libssh2-headers\folder
Then try again your cl ssh2_exec.c: that should be enough for cl to find where the header files are.
I'm trying figure out how to compile C++ code from an executable during runtime using Visual Studio compiler under Windows.
I'll be using Visual Studio IDE to build main project into an executable and use CreateProcess to compile other C++ files and create a DLL to later load/use/unload this DLL.
I understand that one way of doing this requires setting environment variables(mainly PATH, INCLUDE and LIB) and there's a .bat file called "vcvarsall.bat" which does this.
The part I'm stuck with is the argument(s) passed to this batch file. I see that first argument is the platform with some of the options being x86, amd64, arm, etc. But how do I programmatically figure out which one of these arguments I should be using considering main executable could've been built with any one of these?
You can prepare a regular solutionfor this purpose, containing one project with a single file, and use it to compile your file easily.
Now, all you need is to reame your file to the file name in the project and compile a solution with command line. Alternatively, you can also edit the project and replace the existing filename with your file name.
To do so you need to resolve the environment variable %DevEnvDir% and run the folowing command with the platform name (x64, win32 etc.) and configuration name(Release or Debug)
like this:
%DevEnvDir%\devenv.com \path\to\yoursolution.sln /ReBuild "Release|x64"
I would like to solve this issue once for all, what is the best best to compile a .cpp file that uses windows libraries (to create a exe file).
For instance I have this cpp starting with:
#include "stdafx.h"
#include <Windows.h>
And I get
stdafx.h: No such file or directory
Windows.h: No such file or directory
I know for instance that stdafx require Visual C++ on Windows, but I want to compile it on Linux, how would you do ?
Thanks a lot
The short answer is you cannot build a Windows executable on Linux. But you can download the free Visual Studio Community Edition to build it on Windows.
stdafx.h is a header file in your project. It is used by Visual Studio's pre-compiled headers feature. If you use a predefined project template, Visual Studio will auto-generate stdafx.h and mark it for pre-compilation. You then include the common C++ headers, e.g. STL, in stdafx.h and include stdafx.h in each of your source code files.
When you are not using Visual Studio stdafx.h is a convenient place to pull in the standard headers for runtime libraries but serves no other purpose.
windows.h is the header file for Windows runtime APIs. The Windows APIs and hence the headers are not available on Linux. If you want to build an executable on Linux to run on Linux then you must replace Windows APIs with the Linux equivalents.
I have searched high and low for this answer. I have tried suggestions to similar problems posted on Stack and other sites. My toolchain consists of an x64 machine with windows 7, visual studio 2010, opencv 2.4, qt 4.8, and boost. I configure all of my projects using CMake, which finds all of these libraries and includes and creates my visual studio project. I have compiled two versions of boost, a 32-bit version build in the command line and placed in \boost\boost_1_47_0\lib\win32, and a 64-bit compiled in the Windows SDK v7.1 64-bit compiler and stored in \boost\boost_1_47_0\lib\x64. Everything in the project compiles fine with the exception of boost. I get a compiler error:
fatal error LNK1104: cannot open file 'libboost_filesystem-vc100-mt-1_47.lib'
As a reminder, CMake is handling all of my linking and it properly locates this lib and adds it to the visual studio project. I can verify this by looking at Properties->Linker->Command Line. Here, in addition to files representing other libraries, it has listed:
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_filesystem-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_program_options-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_date_time-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_thread-vc100-mt-1_47.lib"
I can suppress this error by manually adding my boost\boost_1_47_0\lib\x64 directory to Properties->Linker->General->Additional Library Dependencies. This compiles without error. However, when I go to run the application, I am met with a system error that tells me:
The program can't start because boost_filesystem-vc100-mt-1_47.dll is missing from your computer. Try reinstalling the program to fix this problem.
In this /x64 directory I have:
boost_filesystem-vc100-mt-1_47.dll
boost_filesystem-vc100-mt-1_47.lib
libboost_filesystem-vc-100-mt-1_47.dll
Any insight would be incredibly appreciated. Thanks!
To solve the runtime error:
Add the location of the dll(s) to the PATH environment variable.
For example on my machine:
set PATH=%PATH%;c:\users\chris\boost_regex-vc140.1.63.0.0\lib\native\address-model-32\lib
or copy the dll(s) to a directory already in the PATH
See here: https://msdn.microsoft.com/en-us/library/7d83bc18.aspx?f=255&MSPPError=-2147217396
This project consists of a single .cpp file which calls LoadLibrary() to load a dll-file.
What happens is that if I run the following through the Microsoft Visual Studio 2012 Command Prompt:
cl /nologo Test.cpp
Everything works fine.
On the other hand, if I start up a simple Visual C++ project, add the file and compile it through there, the LoadLibrary() call fails with code 126: The specified module could not be found.
The .exe I build from the command line is more than twice the size of the one built in Visual Studio. So I guess there's some static linking going on.
The .dll-file is fine, and it's in the same directory as the .exe-file.
I figured it out.
By default the cl command uses the multibyte character set. While new projects set up in Visual Studio are configured for unicode.
if Loadlibrary function fails with error 126
that clearly shows that it was not able to find the library.
so you can check this function by appling full path in Loadlibrary's argument.
if it works then set that path in PATH variable of system environment variable.
because Loadlibrary api first find that full path, if it was not able to find the library at that path then it search it in systems standard PATH.
does your operating system is 64-bit it?
I have encountered this situation on my win7(64-bit), but not in VS,photoshop(64-bit), matlab-2011a(64bit). Prompts are the same: Loadlibrary failed with error 126 ...
As far as I know,“they’re missing a registry entry critical to its functionality. Specifically, whenever an application requests OpenGL access, AMD’s atig6pxx.dll kicks in. It then peeks inside HKLM\SYSTEM\CurrentControlSet\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\0000 and loads the OpenGL component as specified by OpenGLVendorName (64-bit) or OpenGLVendorNameWow (32-bit).”
You can refer to this blog(enter link description here), and it gives the solution。I tried and it worked.or you can refer to this forum(enter link description here)。
I hope it could solve your problem,go luck:)