I recently learned about Visual Studio Code & Intellisense and am currently writing code on that and trying to compile it using Cygwin. However, I'm never able to do it.
I have added C:\cygwin64\binand%systemdrive%:\cygwin\bin` to my system environment variables in settings. I'm doing this on a Windows 11 computer. But every time I try to compile a program, like:
gcc HelloWorld.c
I get:
cc1: fatal error: HelloWorld.c: No such file or directory
compilation terminated.
In file explorer, all the programs I'm trying to compile say "Availability status: error". Specifically, any programs (regardless of language) I have downloaded onto my computer hard drive are apparently unavailable. What does this mean?
I tried using MSYS Mingw-w64 but the same problem happens. I thought that I might not have included the "gcc-core" compiler file when I downloaded it, so i did that again with the file but nothing. I typed "gcc --version" and "gdb -- version" to check and debug but the same messages pop up, both for Cygwin and Mingw.
I tried using other text editors (notepad and vim) to type, but they didn't have any effect. I thought they might create compileable, "available" files on file explorer.
Related
Currently using VSCode on Windows for development, including C files. However, including unix header files (like <unistd.h>) results in VSCode thinking that there is an error. The current compiler path is "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" but there is a working GCC installed in WSL which is the main compiler I want to use.
Using wsl gcc to compile files works and the files run normally. There is an option for "Compiler path" and "Include path" in the Microsoft C/C++ Extension, but WSL paths (such as "\wsl.localhost", "//wsl$/Ubuntu/", "/usr/local" etc.) are not recognised by either option. Opening another VSCode window in WSL remote mode works, but doing that just for C files specifically is very slow. Is there a way to specify a configuration for non WSL VSCode windows to use the WSL GCC compiler for C code analysis?
The most important thing to do is set the compiler path.If you do that, you won't need to manually set the system to include paths and defines.
VS Code Website
I'm using Visual Studio 2019 (Community Edition). I've never had an issue when compiling C++ code. I simply get the final executable and I'm able to run it without a problem. Recently I've decided to learn C and this is the C program that I'm compiling:
#include <stdio.h>
int main()
{
printf("Hello, world! \n");
return 0;
}
The file name is "main.c".
I haven't changed any of the default project settings and the project that I selected was "empty C/C++ project".
The code compiles fine but when I attempt to run the executable I get this error:
Unable to start program [path to .exe file]
Operation did not complete successfully because the file contains a
virus or potentially unwanted software.
I can resolve this issue by going to Windows Defender and manually allowing this detected threat but obviously the issue with this approach is that other people won't be able to run my C programs without them being detected as a virus.
Ultimately, I believe this problem is related to how VS2019 is compiling my program rather than Windows Defender because I'm able to compile C++ (and other languages) into executables that run perfectly fine.
I tried to use VC++ commandline, instead of MinGW compiler for windows system programming. I wrote a simple hello world program and tried to compile it, then i got this error message.
test2.c(1): fatal error C1083:'stdio.h': No such file or directory
I also added "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86" directory (where c1.dll lives) to the System Envionment Variable(PATH).
How can I fix this issue? Other tutorials don't give much information about VC++. (A lot of MinGW compiler tutorial out there btw)
You should use visual studio command line if you want to compile or run program with the help of vc++ compiler.
Else all information related to setting environment variables ETC. resides in this MSDN document.
I am currently attempting to compile and run a C program in eclipse. The problem is, every time I attempt to run a program, the same error shows up.
The image shows the error that is displayed. I am not sure what to get out of that error.
I currently have cygwin installed, and am able to run gcc and g++ on the command prompt. I also have PE Windows Parser and Cygwin PE parser enabled under Binary Parsers. I have also cleaned and built the project many times over.
I'm cross-compiling a project from Linux to target Windows (using mingw). The output is a DLL and p-invoking into it from C# works, but debugging is very difficult. The build outputs a .o file, which can provide symbols to gdb, but basically all I can do there is break on exceptions and find the name of the function that was executing when the exception happened; not even the full stack trace. I can't debug with WinDbg because I don't have .pdb files.
This is an open source project set up to build on Linux; I believe their build process relies on several installed Linux packages to work.
Do I have any options here? Is there a utility that can convert .o files into .pdb? Or some program that can give me more information than gdb when debugging?
Try a IDE that support mingw. For example the open source Code::blocks.
Another possibility is to do it manually: compile it with debug symbols, start you application and attach the GDB debugger to it. It is also part of the MingW32 distribution. Then you can set your breakpoints and debug your application
But I guess using Code::Block is more comfortable
By the way, the GCC compiler does not generate pdb files because it is a propietary format
What xpol means is maybe: if you have a complete mingw installation then Code::blocks can use gdb to visualize a debugging session like it is done in Visual Studio or Eclipse. See chapter "Debugger" at http://www.codeblocks.org/features
You can generate a .pdb file using cv2pdb.exe from Visual D. This works even for programs not written in D if they were compiled with mingw. Once you've downloaded and installed Visual D cv2pdb.exe can be found at C:\Program Files (x86)\VisualD\cv2pdb\cv2pdb.exe.
You can run cv2pdb.exe against an executable like this:
cv2pdb.exe -n target.exe
This will produce a file called target.pdb. Assuming both target.pdb and target.exe are in the current director, you can then use windbg like this:
windbg -sflags 0x80030377 -y . -z target.dmp
In this case I'm also passing a minidump file as target.dmp. This can be omitted. The -sflags 0x80030377 option tells windbg to load target.pdb even though it thinks it doesn't match target.exe.
Note, that it can take windbg a very long time to load target.pdb. Just wait until it no longer says *BUSY* to the left of the command entry box.
Alternatively you can try DrMinGW.