Hi,

I am Fedora Core 5 32+ bit os. I am a self taught guy and currently trying to get my head around the basics of C++ programming. I am at the moment using the command prompt only, to compile and run the small programs written in C++. Just a while ago I came across this site and something caught my attention, that was nothing else but some really basic interfaces consisting of menus, buttons etc written in C++. So I downloaded some of the code which was in zip format and unzipped the whole thing in a folder. Here is the web page.

I have attached the screen shot/image (it is from my other machine which has Win xp just to show people here) to this post showing just how many different types of files the unzipped package/source code contains. I am still not used to any particular IDEs on Linux in order to be able to put all these files in one big project. So I was wondering if I keep them all in one folder as they are at the moment on my Linux machine and compile + run them from the command line/terminal itself without using any particular IDEs that work with Linux for example the Eclipse one. Thanks .....

Dani AI

Generated

Quick practical guide for building a downloaded C++ sample entirely from the terminal (no IDE).

First, confirm the code is actually portable. Many GUI/menu samples on the web target Windows APIs; signs include files or lines referencing windows.h, .rc resource files, .sln / .vcproj files, or libraries named *.lib/.dll. If you see those, the code will not compile on a stock Linux toolchain without porting or using a Windows-compatible toolchain. If the project is cross‑platform it usually contains plain .cpp/.h sources or build files like Makefile, CMakeLists.txt or configure scripts.

Quick workflow:

  • Locate the implementation files and the program entry point. From the project root run, for example:
    find . -type f \( -name '*.cpp' -o -name '*.cc' -o -name '*.c' \) -print
    grep -R "int main" .
  • If there are only headers, you need a small driver main that instantiates the classes. ( noted this — it’s the usual case for header libraries.)

A minimal, reusable Makefile you can drop in the root (keeps commands generic and portable):

CXX ?= c++
CXXFLAGS ?= -O2 -Wall -std=c++17 -Iinclude
SRCS := $(wildcard src/*.cpp) $(wildcard *.cpp)
OBJS := $(SRCS:.cpp=.o)
TARGET := myapp

all: $(TARGET)

$(TARGET): $(OBJS)
    $(CXX) $(LDFLAGS) -o $@ $^

%.o: %.cpp
    $(CXX) $(CXXFLAGS) -c -o $@ $<

clean:
    rm -f $(OBJS) $(TARGET)

.PHONY: all clean

This follows the Makefile approach recommended by and but is ready-to-run: adjust CXXFLAGS, include dirs, and library flags as needed.

Troubleshooting tips: read any README/INSTALL first; missing headers mean add -I paths, undefined references mean add -L/-l for libraries (watch link order). If the project includes configure or CMakeLists.txt, consider those tools for larger builds (as hinted, autotools/CMake scale better). If compilation still fails, paste the first error lines — they usually show the root cause.

Recommended Answers

All 5 Replies

Usually if you're working on a project in Linux through a command line environment, you likely should be using a Makefile to build your app. If you're not going to use make and similar tools, then you probably should use an IDE for any sizeable project.

Like Infarction said, Makefiles are the way to go if you do not have/want an IDE. Personally I think IDEs are awful and a scourge to programming but thats just my opinion ;-) I usually just have a Makefile and use Emacs.

All hail GNU autotools.

What you seem to have downloaded, are headers for using menus in a program. To actually use these as a program, you would need to write a program that makes use of, and creates instances of, these headers and classes.

Then you need to compile and link it, using g++ .

Thanks for the help guys..

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.