问题
I'm currently learning to code in C and I use Cygwin64 to compile the code, as of now I'm using Notepad++ as my text editor and I would like to be able to compile my code using the plugin nppexec instead of having to close notepad++, compile and then open it again. The only problem is that the majority of nppexec scripts for C use mingw and not cygwin, Are there any nppexec scripts for C that use cygwin64?
回答1:
Something like this: Final Setup of gcc in Notepad++ [using nppexec] ?
Notepad++ is a great program, but it's hardly an IDE. It doesn't understand your code so it can't do smart code completion and doesn't allow you to do any debugging.
For example Code::Blocks is a good free IDE.
Also, if you want to learn C, I don't see why you use Cygwin. Only use Cygwin if you really need to port Linux/Unix stuff to Windows that won't build with other toolchains.
You should go for MinGW-w64 instead.
回答2:
Are there any scripts for compiling C code with cygwin for nppexec?
Do yourself a favor, learn to use the command line interface.
Read the Modern C book.
Avoid weird characters (notably spaces) in C source file names. So use foo-bar.c
not foo bar.c
For your source code editor, consider GNU emacs or vim or Visual Studio Code (or some other IDE of your choice). But remember that most C compiler programs (including tinycc, nwcc, GCC -which cygwin
provides-, Clang, even Visual Studio is at heart its cl
command) are transforming a C translation unit (practically your foo.c
file) into an object file (e.g. foo.obj
on Windows, foo.o
on Linux or MacOSX) and don't have natively any GUI for that. Later some linker is needed.
Compile thru a build automation tool such as ninja or GNU make.
Use a version control system, such as git.
In many cases, it is interesting to generate some of your C code (so called meta-programming approaches). Look into tools like SWIG, ANTLR, GNU bison, rpcgen, or those supporting ASN-1 listed here. For GUI interfaces, consider using GTK and related code generator tools, such as Ggen. For JSONRPC services, see jsvggen. With a command line interface approach, taking advantage of these tools is easy. Look also, for inspiration, into the open source code of many bootstrapped source to source compilers emitting C code, such as Bigloo or Chicken/Scheme or S48.
Learn to use a debugger, such as GDB or LLDB. Debugging information (e.g. DWARF) needs special flags at compilation time, so with GCC, use gcc -Wall -Wextra -g
to get warnings and debug info.
Cygwin is wrapping the GCC compiler.
For embedded cross-compilation for Arduino or RaspBerryPI devices, the C cross-compiler is also a command-line tool.
Spend several days to read the documentation of cygwin and of GCC.
Of course, read the documentation of every tool mentioned here.
Cygwin is Unix inspired, so be aware of the Unix philosophy.
NppExec is a plugin for Notepad++ which has its documentation somewhere.
For inspiration, study the source code of existing open source software on github and gitlab.
PS. Consider perhaps installing a newbie-friendly Linux distribution such as Debian or Ubuntu on your PC laptop (if you prefer the original: a good GNU/Linux distribution to its imitation: Cygwin). Be sure to backup your important data before trying. You'll need a hundred gigabytes of disk space to be at ease, and you could have a dual boot setting: Linux for software development, Windows for games.
PPS: every software mentioned above (except some MicroSoft compilers) is open source and exists on Debian or on Ubuntu. You could later be interested by Linux From Scratch. Read also for your information this draft report (work in progress in June 2020).
回答3:
Cygwin includes the mingw cross-compilers. Look for the mingw64-i686-gcc-g++ and mingw64-x86_64-gcc-g++ packages in cygwin setup. These are almost the same compiler packages you can install with pacman when you have installed the mingw64 system.
In your makefile, change CC=gcc to CC=/bin/x86_64-w64-mingw32-gcc.exe to compile 64 bit exe's, or CC=/bin/x86_64-pc-cygwin-gcc.exe for 32 bit exe's. The resulting executables do not depend on the cygwin DLL. In the simplest cases, they only depend on windows DLLs.
There is a huge collection of mingw64 packages available to install.
回答4:
Do yourself a favour, do not learn to use the command line at this stage.
If you use Windows 10 install VisualStudio
You do need cygwin anymore as Windows 10 has native Linux subsystem. You can install your favourite distribution there (I would recommend the Ubuntu as the instructions are for Ubuntu).
Follow the instruction: https://devblogs.microsoft.com/cppblog/targeting-windows-subsystem-for-linux-from-visual-studio/
Enjoy.
When you learn C a bit you can start to learn make or other build systems. Learning command line GDB IMO in 21st century is not needed at all. There are so many convenient GUIs and integrated environments for it
来源:https://stackoverflow.com/questions/62433657/are-there-any-scripts-for-compiling-c-code-with-cygwin-for-nppexec