I'm trying to setup local Windows eclipse for remote Linux development. I have encountered problem with eclipse not recognizing simple 'printf()' statement from <stdio.h>. I didn't find any helpful resources ATM to solve this problem, so wondering if you could help me with this.
Header files used from: Visual Studio Build Tools 2022, specifically I'm including this folder for stdio.h file: 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041\ucrt'
GCC C++ Compiler as: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin\clang.exe"
Eclipse IDE still highlights this as 'Function cannot be resolved':
I am not sure, but looks like 'printf' function is available at 'stdio.h':
Update:
Eclipse version used:
Using command line build is working as expected:
Program runs as expected:
So the questions are:
What needs to be done so eclipse would recognize 'printf'? e.g. Change MS Win Kits for another compiler header files? Or my eclipse configs are wrong?
If it is not possible for eclipse to recognize 'printf', is there an option to ignore all warnings on 'printf' (not highlight them)?
Let me know would you need anymore details from my side.
After some investigation I think 'clang' is not compatible with eclipse & it's way easier to install & use 'cygwin' for such purposes.
Some references:
https://www.eclipse.org/forums/index.php/t/1092409/
https://www.eclipse.org/forums/index.php/t/1102938/
Related
Does anyone know of a way to read from a file in CMake, that works in Visual Studio? I have a cross-platform App. in Visual Studio 2017 that compiles with a toolchain in Linux, running in Hyper-V.
I have a simple defined version number in one of my H-files that I would like to read, parse, and append version number to the name of the compiled program (e.g., company_app_1.2.3).
I can't seem to get the file(READ) command to work. Visual Studio is using CMake version 3.11. I assume CMake can do this regardless of the g++ toolchain being used.
Command I tried:
#Read version
-file(READ FileNameHere $sValue)
Visual Studio Error I get:
1>/bin/sh: -c: line 0: syntax error near unexpected token `READ'
The MakeFile does not have a .txt extension, of follow Visual Studio's naming convention, but I would be willing to rename it if there was an advantage (intellisense available, or some more info about the error).
Thanks in advance for any replies.
I've just installed Visual Studio Code v1.7.1 to write my c++ code in for my degree. My programming level is pretty basic, but I like what I've seen of VS Code so far, save for the fact that I've no idea how to debug or build my code.
I've looked at a few questions on the topic, such as: How do I set up VSCode to compile C++ code?
and have tried implementing some of these into the tasks.json file, including the make command and the g++ command, but when I try and execute it I get the error:
'make' is not recognized as an internal or external command,
operable program or batch file.
or something similar. When I try running the debugger, it tells me to set up the launch.json file, so I entered the path of my file where it says 'program' as the instructions imply, I get the error
Unknown Error: 0x800700c1
I'm just looking for the simplest option that will allow me to write and debug code in vs code, in a manner similar to using the full version of visual studio, but without the heavy project filing system or the 10 minute loading times. Any help would be greatly appreciated.
What I deduce from your question and the comments is that you have no actual C++ compiler/buildchain installed. There are multiple compilers available (like minGW, GCC).
However, what Microsoft recommends is the following:
Installing C/C++ build tools
To obtain your set of C/C++ compilers on Windows you can grab the Visual C++ build tools SKU. By default these tools are installed at ‘C:\Program Files (x86)\Microsoft Visual C++ Build Tools’.
I have not tested, nor ever worked with the Visual C++ compiler, but it's probably the easiest way to get started right away.
I've installeed Netbeans 7.0.1 and MinGW on my computer, but when I tried to build a project, it shows the error message:
I googled the problem, and every solution said that I need to add MYSY to Path, so I did it; and restarted netbeans, but the problem still shows up, I'm thinking about maybe it's because I installed Qt4.7.4 so there maybe some conflicts in %Path%,
here is the two Paths in my computer:
User variables for shengy:
C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program
Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft
Visual Studio\VC98\bin;C:\Program Files\IDM Computer
Solutions\UltraEdit\;C:\boost_1_34_1;C:\Program
Files\Telelogic\Telelogic Synergy 6.5\bin;C:\Program
Files\Telelogic\Telelogic Synergy 6.5\lib;
System variables:
C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program
Files\doxygen\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program
Files\COSMIC\CXS12X;C:\COSMIC\CX12;C:\Program Files\PC Connectivity
Solution\;C:\shengy\ComplieCommands;C:\QtSDK\Desktop\Qt\4.7.3\mingw\lib;C:\Program
Files\Telelogic\Telelogic Synergy
6.5\bin;C:\MinGW\msys\1.0\bin;C:\MinGW\bin;
please help me about this. Thanks
make shure you have set the correct tool collection for mingw (options -> C/C++ -> Build tools, Base directory: C:\MinGW\bin).
All compilers / commands (excluding make / qmake) should point to there too.
Also make shure ...
you can run mkdir from cmd
if qt ships its own MinGW: you use yours (maybe you can remove the one from qt)
move the path variables from mingw before the one from qt
See:
MinGW Compilers and Tools
This Answer
edit: does C:\shengy\ComplieCommands contain any mingw / gcc programs?
i had a problem like it. i think you should install MYSY (as you did) and then adjust netbeans like below:tools->c/c++ -> build tools -> make command set to mysys\bin\make.exe
How can i get C++ coding in eclipse to act like coding in java?
In java, i can nicely add external jar files and the code assist can nicely suggest methods or suggest adding unimplemented methods for interfaces.
But in C++ mode, it doesn't seem to work when i include external header files. What else should i try?
Eclipse CDT itself does not come with any compilers/libraries therefore you need to select and install a toolchain. There are a few options for this
Visual Studio (cl)
MinGW (g++)
Cygwin (g++)
Note, you can get VS Express for free and if you are a student can even get the professional version from Dreamspark
Once you have installed any of these you can select them as the toolchain for your C/C++ projects, this will enable you to build your projects nicely from within eclipse.
Also, you may need to point eclipse to the library files used by your compiler, for instance I use the VS2010 toolchain under Eclipse CDT so I must add
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
to the include directories in build settings.
Edit: Sorry if it wasn't clear, once you've done this code completion should work for your C/C++ projects.
I'm now going to give c++ a try to see what this language have to offer. I'm having some trouble setting it all up though. I have downloaded Eclipse CDT and followed this guide : http://www.dcs.vein.hu/bertok/oktatas/cpp_by_eclipse/eclipse_for_cpp_on_windows.html#Install_gdb
I am using Windows 7 64bit.
I have never installed a compiler before, and I'm not sure what exactly I am doing wrong. It gives me an "Launch failed. no binary found" error when I try to run my program. However there is no binaries folder. I have tried building, it loads for a while, but nothing really happens.
Any idea what to do? I am completely new at c++ so please be patient and let me know if there's anything I am missing :)
The console in eclipse says the following:
Build of configuration Debug for project Test2 **
Internal Builder is used for build ** cl /c /EHs /MD /Zi /nologo /Fospam.obj ..\spam.cpp Internal Builder: Cannot run program "cl" (in directory "C:\cppworkspace\Test2\Debug"): CreateProcess error=2, Den angivne fil blev ikke fundet Error: Program "cl" is not found in PATH
PATH=[C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x86;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\MinGW\bin] Build error occurred, build is stopped Time consumed: 156 ms.
If you will compile with Eclipse CDT + MingGW Compiler you should use the MinGW toolchain
MingW Toolchain
If you want use Eclipse + Microsoft C++ compiler, need change for "Microsoft Visual C++" toolchain and put in PATH
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
or whatever you have because CL program is there...
The problem is simple enough, Eclipse can't find your compiler.
On the lengthy PATH that is quoted I don't see 'c:\MinGW\bin' so I'm guessing you had problems with step 4 under section install MinGW.
Having said all that I don't think Eclipse is a very good environment for developing C++ and I don't think MinGW is a particularly good compiler. I'd seriously recommend you take a look at Visual C++ 2010 Express, which you can download from here http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express
EDIT
OK now I do see 'c:\MinGW\bin', so apologies for that. I think the likely explanation is that you have selected the wrong 'tool chain'. Eclipse thinks you want to build with Visual C++ but you have downloaded MinGW. But really get Visual C++ 2010 Express and forget about Eclipse, it's much easier.