Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:02:11+00:00 2026-05-27T08:02:11+00:00

I have written c++ program on NetBeans, now I want to run it on

  • 0

I have written c++ program on NetBeans, now I want to run it on Linux on command line. How can I write Makefile, what is the logic of writing it?

I have 3 .cpp files and 2 .hpp files.

This is what I have tried to do:

# Makefile

# the C++ compiler
CXX     = g++
CC      = $(CXX)

# options to pass to the compiler
CXXFLAGS = -Wall -ansi -O2 -g
Run: Run.cpp Assessment3.o Student.o
$(CXX) $(CXXFLAGS) Run.cpp Assessment3.o Student.o -o Run

Run: Run.cpp Assessment3.hpp  Assessment3.o Student.o
 $(CXX) $(CXXFLAGS) Run.cpp Assessment3.o Student.o -o Run  

Assessment3.o: Assessment3.cpp Assessment3.hpp
$(CXX) $(CXXFLAGS)  -c Assessment3.cpp

Student.o: Student.cpp Assessment3.o
    $(CXX) $(CXXFLAGS) -c Student.cpp 

It gives me ‘missing separator. Stop.’ error on command line. It is not saying that this is an error though.
Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:02:12+00:00Added an answer on May 27, 2026 at 8:02 am

    Assuming you want to build an executable named foo, you can just use a simple makefile which builds everything in one go with just one dependency :

    # makefile 
    
    SRCS = a.cpp b.cpp c.cpp
    
    HDRS = a.h b.h
    
    CXXFLAGS = -Wall
    
    foo: $(SRCS) $(HDRS)
        g++ $(CXXFLAGS) $(SRCS) -o $@
    

    EDIT

    Alternatively, taking your initial makefile above and fixing a few minor problems:

    # Makefile
    
    # the C++ compiler
    CXX     = g++
    CC      = $(CXX)
    
    # options to pass to the compiler
    CXXFLAGS = -Wall -ansi -O2 -g
    
    Run: Run.o Assessment3.o Student.o
        $(CXX) $(CXXFLAGS) Run.o Assessment3.o Student.o -o $@
    
    Run.o: Run.cpp
        $(CXX) $(CXXFLAGS) Run.cpp -o $@  
    
    Assessment3.o: Assessment3.cpp Assessment3.hpp
        $(CXX) $(CXXFLAGS) -c Assessment3.cpp -o $@
    
    Student.o: Student.cpp Student.hpp
        $(CXX) $(CXXFLAGS) -c Student.cpp -o $@
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a c program that retrieves arguments from the command line under
I have written a C++ program for a University assignment. I used Netbeans 6.8
Visual Studio C++ 2008 / GCC 4.4.2 I have written a program to run
I have written program for drawing pythagoras tree fractal. Can anybody see any way
I have written a small program and compiled it under Solaris/Linux platform to measure
I have written a program which opens a file then displays line by line
I have written a program that relies on a proxy to function. I now
I have written a program in C# to use SQL 2008. I want to
I have written a program. When I hit the Enter key, I want the
I have successfully written a video processing program. I used ubuntu and Netbeans for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.