Why Visual Studio Code can't compile my C code? - c

I have a problem which is: VSC can't compile my C code as the title said. I have looked for the problems and did all what was necessary:
installed msys
installed mingw
installed C/C++ extensions
added code runner
Yet the problem is still showing like this:
gcc.exe: error: name.c: No such file or directory
(Note that I'm an absolute beginner when it comes to using VSC and don't have any background in coding so I'd appreciate it if I get to know the solution by simple vocabulary :) )

It seems like your c file('name.c') is not located in your working directory.
Moving your c file to your project folder may solve your problem.
To check your working directory, choose terminal tab and type 'pwd'.

Related

CLion does not recognize CMakeLists.txt file

I am currently trying to set up CLion, as I like IntelliJ a lot, and I ran into this seemingly very basic problem:
CMake Error: The source directory "/cygdrive/c/.../untitled" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
This happens even when building a clean C project from scratch in CLion, where a CMakeLists.txt file is present in exactly that directory. I use cygwin64 as compiler and work on a Windows x64 machine. I guess /cygdrive/ before c is due to that.
Sorry to bother you guys with that basic stuff, but I simply cannot work it out. I know there are a lot of similar questions around, unfortunately that did not help me.

Eclipse C/C++ does not want to run an app, outputting an Error -.-

Alright, hello guys. I've been using Eclipse Luna for some time now while programming in Java. Recently, due to school work, I decided to download the C/C++ for the eclipse as well. I have installed it and all went well. Then I wrote a simple programme and Eclipse will not run it.
Each time there is a pop up: Launch failed. Binary not found.
Also, Eclipse says there is the following error: Program "make"not found in PATH.
Now, I have tried everything to fix it. I'm using the MinGW. I also downloaded Msys.I added all the necesarry paths into the System enviroment variables and done the same thing in the Eclipse.
I went into the Window -- Preferences -- C/C++ -- New C/C++ project and under Binary Parsers selected the PE Windows Parser. I've tried other things as well, like adding the following line into the eclipse.ini as someone suggested:
-DMINGW_HOME=C:\Program Files (x86)\CodeBlocks\MinGW
Nothing seems to be working though and I sadly cannot run even the simplest of programs. Haalp, please.
Kind regards,
George.

How to use CUDA 6.0 with XCODE 5

My question may completely be a noob. Sorry, for that but I have been trying to compile my first Cuda code in Xcode and I'm lost where and how I could set up the IDE to invoke NVCC.
I installed the latest CUDA toolkit CUDA 6.0 and have even installed GCC 4.8 using brew. I have XCODE 5.5
When I run my code from XCODE all the directives like global are marked as unidentified.
I don't where and to change the settings to invoke NVCC. I will be really thankful, if anyone could help me with this.
Further, when I created the XCODE project, I created it as a C project. So, I placed the CUDA code in this C file, which is what is giving me the above mentioned errors. I tried to replace this .C file with a .cu file (just change the extension), which too failed badly - XCODE didn't even know what to do with the .cu files
COuld anyone please help me?
Thanks in Advance
I have given it a try. Although I have not completely succeeded I thought I'd post my progress here in hopes of helping others. The steps I took were inspired by this page.
Create a new Xcode project
Under Build Settings add a new user defined setting CC with the value /usr/local/cuda/bin/nvcc.
Add /usr/local/cuda/include to Header Search Paths under Build Settings.
Set Enable Modules (C and Objective-C) to No.
Add /usr/local/cuda/lib/libcuda.dylib to Link Binary With Libraries under Build Phases.
For any C files you create set their extension to .cu in the File Inspector, after you have done that you have to set the type of that file to C source to get syntax highlighting, by going to Editor->Syntax Coloring->C.
Problems with this setup:
- Xcode can't run the executable, at least nog if it is compiled for debugging. However you can make it copy the executable to some reasonable location and run it in the terminal.
- Whenever you try 'Build for running' sometimes Xcode magically destroys the whole project.

Source file not compiled Dev C++

I just installed Dev C++ and I am learning C programming.
the code i used was
#include <stdio.h>
int main()
{
printf("Hello world");
getch();
}
I saved it as a .c file. When I compile it works fine, but when I compile and run it says source file not compiled. So I googled buncha things and came across this video on youtube which shows you how to fix it. I also saw other forums on google which suggest the same thing... However, after doing whats asked, Now I can't even compile my code. I get this error
Compiler: Default compiler
Executing C:\Dev-Cpp\bin\gcc.exe...
C:\Dev-Cpp\bin\gcc.exe "C:\Users\ubaid\Documents\C\Untitled1.c" -o "C:\Users\ubaid\Documents\C\Untitled1.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
gcc.exe: Internal error: Aborted (program collect2)
Please submit a full bug report.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.
Execution terminated
I have also used what is asked on this link, and still no luck..
http://learntogeek.com/miscellaneous/solved-source-file-not-compiled-error-in-dev-cpp/
I am using windows 8
I was having this issue and fixed it by going to:
C:\Dev-Cpp\libexec\gcc\mingw32\3.4.2
, then deleting collect2.exe
Install new version of Dev c++. It works fine in Windows 8. It also supports 64 bit version.
Download link is http://sourceforge.net/projects/orwelldevcpp/ .
I guess you're using windows 7 with the Orwell Dev CPP
This version of Dev CPP is good for windows 8 only. However on Windows 7 you need the older version of it which is devcpp-4.9.9.2_setup.exe
Download it from the link and use it.
(Don't forget to uninstall any other version already installed on your pc)
Also note that the older version does not work with windows 8.
This maybe because the c compiler is designed to work in linux.I had this problem too and to fix it go to tools and select compiler options.In the box click on programs
Now you will see a tab with gcc and make and the respective path to it.Edit the gcc and make path to use mingw32-c++.exe and mingw32-make.exe respectively.Now it will work.
The reason was that you were using compilers built for linux.
You can always try doing it manually from the command prompt. Navigate to the path of the file and type:
gcc filename.c -o filename
I found a solution. Please follow the following steps:
Right Click the My comp. Icon
Click Advanced Setting.
CLick Environment Variable. On the top part of Environment Variable Click New
Set Variable name as: PATH then
Set Variable Value as: (" the location of g++ .exe" )
For ex. C:\Program Files (x86)\Dev-Cpp\MinGW64\bin
Click OK
This error occurred because your settings are not correct.
For example I receive
cannot open output file Project1.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [Project1.exe] Error 1
Because I have no permission to write on my exe file.
After some investigation, and with Dr.Topaz's help, I have learned that you will want to confirm that the program set for g++ in the Compiler Options really does compile the source code. In my case, the C:\Dev-Cpp\bin\g++.exe program did not create an exe, but the C:\Dev-Cpp\bin\c++.exe program did. Either program appears to be intended to take the same arguments and options as GNU g++. I would love to find an actual doc on the Dev-C++ compiler programs, but I have not so far.
You can test the compiler program with a simple example like this:
C:\Dev-Cpp\bin\c++.exe hello.cpp -o hello.exe
Currently in 2021, the Dev-C++ site invites you to download either original Dev-C++ or a newer fork by a group named Embarcadero.
I decided to try the Embarcadero version and the experience was slightly better. The UI is still a tad dated, but the g++.exe program it came with was able to compile programs without issue. Again, take note of where the program is being installed, but in my case, the Embarcadero compiler programs were in C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\bin.
Both original Dev-C++ and Embarcadero come with mingw-32 versions of the compiler programs that from what I see do work in a Git Bash console, with slight differences such as not recognizing a default locale when using the command std::cout.imbue(std::locale("")).
I faced this similar error, and none of the solutions worked.
so I tried to download the latest version from here, https://www.bloodshed.net/
I rerun the program.
and everything is now working correctly.
I was facing the same issue as described above.
It can be resolved by creating a new project and creating a new file in that project.
Save the file and then try to build and run.
Hope that helps. :)

Error - Compiling Gnuplot on Windows 7 using nmake and makefile.nt

Gnuplot experts or anyone who is willing to help me - I have explained what I have done in very simple words and in a detailed manner. Thanks for your time and patience in advance.
My aim is to develop a new feature in Gnuplot by adding a new terminal to it. I did the following steps in the order mentioned
I formatted my system and reinstalled Windows 7. (no antivirus installed)
Installed Visual Studio 2008
Downloaded the source code of Gnuplot
Now, am supposed to set up the compiling environment for Gnuplot in Windows. So, I did the following steps as per the instructions in "README" and "INSTALL" files in the source code package.
Opened up Visual Studio 2008 Command Prompt
changed directory to the "src" folder in the source code
Then I ran the nmake tool (the make tool meant for Visual Studio) using the file makefile.nt (which is for Windows)
nmake -f C:\Users.........\config\makefile.nt
It compiled successfully and gave the wgnuplot.exe and gnuplot.exe files as output. Also the manifest files were created. (Note: I have not changed any piece of code from the original source code package)
When I tried to open the exe file generated from the compilation, it threw me this error
The program can't start because MSVCR90.DLL is missing from your computer. Try re-installing the program to fix this problem.
This MSVCR90.dll should be installed already when Visual Studio was installed. I checked the C:\Windows\winsxs\x86_microsoft.vc90... folder and the MSVCR90.DLL was alread there. Then, I tried 2 things to solve this -
Anything to do with PATH variable? I made the PATH variable point to that directory. It threw me a new error that says
Microsoft Visual C++ Library. Run time error. R6034. Here is the detailed picture of the error
So, I reset my path variable back to the old value and followed the steps in THIS FORUM POST to fix the missing dll problem by copying the dll files to the C:\Windows\system32 folder. Again it threw me the same run time error
AM STUCK AT THIS POINT. Please advise me on how to rectify this
problem. THANKS A MILLION :) Advance thanks to you :)
Is there any reason you need to use VS2008?
If not I'd recommend to use the current VC release.
Your problem looks like some sort of version mismatch/incompablilty issue to me ...

Resources