I'm just wondering what everyone thinks about building from the command line. I've been using Code::blocks with a MinGW compiler but there always seems to be a myriad of problems in building projects. I'm starting to become a little fed up with it's querks though it is probably partially my fault.

Often when I ask questions on forums they give me a command line solution for compiling projects. Whilst I'm not overly familiar with it I'm wondering what everyone thinks about it. Is it better to send my compiler instructions from the command line or use an IDE to compile. I know that an IDE has it's advantages such as preprogrammed libraries etc.

Any thoughts? Hope my question makes sense.

making c++ program using command line argument
1. make a file named(say) filemarks.cpp
2. make a executable file and run this file using command prompt.
3.command prompt usually specify the drive and directory we are usally with in
command prompt can be seen in ms-dos prompt
c:\windows>
c is the drive and windows is the directory .
our executable file is in directory
now how to run that file
c:\windows>marks name result name result i have written because (suppose) i have written a program on marks and in order to have result by name i.e. the output ))
(use turbo c++ compiler)
in this we haven't just written the name of the program but in c++ program that we have written is assumed to have argument for the main function
as follows

int main(int argc,char*argv[])

Currently I am using sublime text(with sublimeclang) for cpp, and I am using cmake for generating makefiles and building. bBuilding from terminal with compiler directly is not a great idea, because when you have a big or medium project, it is hard and pointless to write long commands every time. I would suggest to start with cmake. It will generate makeFile-s and you will just run "make"(you might need some additional packages, that I don't know for windows) command from terminal. Also, another advantage is that when you change only one file, it compiles only that file automatically.

With an IDE you have the convenience of having a lot of things taken care of for you. Any IDE worth its salt should be able to handle any project, regardless of how simple or complex it is. And CodeBlocks is a very good IDE. So IMHO, if you are having problems with it, it's almost certainly something that you haven't got set up correctly (e.g. missing linker settings for 3rd party libraries, missing paths to header files for 3rd party libraries etc.)

But building from the command line can be a good thing. If nothing else, it will at least make you more familiar with the build process, allowing you to better understand/appreciate all of the things that an IDE takes care of for you! :)

Mingw ships with all of the tools you'll need to compile from the command-line and GNU make is one of them. So you don't need to worry about writing long, complex commands on the command line each time you want to build your project (as kvahanyan stated above). You can simply create a makefile for your project and then run make to perform the build process. Many complex projects (past and present) use makefiles with GNU make.

There is an online manual for make here, which is also available to download here.

here is a simple, example makefile. It's for a C program, but it would essentially be the same for a C++ program. The only differences would be that the source files would be listed as .cpp and to compile you'd use g++ instead of cc. Other than that, the makefile would be identical!

Makefiles for a simple project like the one in the link above are relatively easy to create. But when you get into building more complex projects, your makefiles can start to get a bit unwieldy!

Kvahanyan's recommendation of using CMake is a good one though, if you want you could install CMake and use that instead of GNU make. Personally, I'm quite happy using traditional makefiles with GNU make, but CMake is a very valid alternative. I've not really messed with CMake much, but it follows a very similar formula!

Make and CMake both have their own very different syntax, so they are both almost like another programming language that you have to learn. And sometimes it can take a while to get your makefiles to work properly, but it is worth it in the end!

I currently run Linux and I build a majority of my projects from the command line nowadays (even going as far as writing my source files from the command line using vim!). I usually only use an IDE (Codeblocks, KDevelop or QTCreator) when I want to do some RAD/GUI stuff using QT or wxWidgets. I have also installed mingw on my Windows machine at work (along with msys and cygwin), allowing me to build and use various Linux/Unix tools/programs on Windows.

At the end of the day, it's all down to what you want to do. By all means try using makefiles and building from the command line and see how you get on. You might actually prefer it and ditch using an IDE altogether! On the other hand, you might absolutely hate it. In which case it will probably make you appreciate what an IDE actually does for you and make you want to learn how best to use your chosen IDE.

Or if you are more of a pragmatist, depending on the project you are working on; you might just choose between using the command line or using an IDE on a per project basis! Or if you want ultimate flexibility, you could use both (e.g. create a makefile or use CMake to create a command line build system and also set up projects for several IDE's - different versions of VS, CodeBlocks etc.).

I say give it a shot and see how you get on! :)

commented: excellent info +14

If you want 100% control over your software build process, then the only option is (IMO) make w/ appropriate Makefiles, standard compiler, and a command line debugger. I've used many IDE tools such as Visual Studio, Eclipse, Code-Blocks, and others. I always revert to make+Makefile for my serious work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.