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

  • Home
  • SEARCH
  • 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 8328413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:26:09+00:00 2026-06-09T01:26:09+00:00

C++ How do i run makefile output Below is my MakeFile, I want to

  • 0

C++ How do i run makefile output

Below is my MakeFile, I want to ask how do i run my unitTest.cpp, as because when i MakeFile with NetBean, using the MakeFile below, main.exe is actually the main.cpp output

BUT I want to run the output of unitTest.cpp

How do i run unitTest.cpp

# ExampleTests Project

SRCS = main.cpp currencyConverter.cpp unitTest.cpp

HDRS = currencyConverter.h unitTest.h

PROJ = main



# Remaining lines shouldn't need changing

# Here's what they do:

#   - rebuild if any header file or this Makefile changes

#   - include CppUnit as dynamic library

#   - search /opt/local for MacPorts

#   - generate .exe files for Windows

#   - add -enable-auto-import flag for Cygwin only



CC = g++

OBJS = $(SRCS:.cpp=.o)

APP = $(PROJ).exe

CFLAGS = -c -g -Wall -I/opt/local/include

ifeq (,$(findstring CYGWIN,$(shell uname)))

  LDFLAGS = -L/opt/local/lib

else

  LDFLAGS = -L/opt/local/lib -enable-auto-import

endif

LIBS = -lcppunit -ldl



all: $(APP)



$(APP): $(OBJS)

    $(CC) $(LDFLAGS) $(OBJS) -o $(APP) $(LIBS)



%.o: %.cpp $(HDRS)

    $(CC) $(CFLAGS) $< -o $@



clean:

    rm -f *.o $(APP)

Below is my unitTest.cpp

#include "unitTest.h"
#include "currencyConverter.h"

CPPUNIT_TEST_SUITE_REGISTRATION(unitTest);


unitTest::unitTest() {
}

unitTest::~unitTest() {
}

void unitTest::setUp() {
}

void unitTest::tearDown() {
}

void stringToUpper(string&);

void unitTest::testStringLowerToUpper()
{
string str = "ILOVECPLUSPLUS";
string str2 = "IloveCplusplus";

cout << "\nChecking if string 1 '" << str << "' equals string 2 '" << str2 << "'";
CPPUNIT_ASSERT_EQUAL(str,str2);

//this part i will use my stringToUpperFunction to test.
currencyConverter c;

c.stringToUpper(str2);

cout << "\nChecking if string 1 '" << str << "' equals string 2 '" << str2 << "'";
CPPUNIT_ASSERT_EQUAL(str,str2);

}
  • 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-06-09T01:26:10+00:00Added an answer on June 9, 2026 at 1:26 am

    Add another target (e.g. testrunner.exe) dependent on the .cpp files you want to test + your testsuite .cpp files + another .cpp file that consitutes the main() for your testrunner application to your make file. Having this you can add another target test, dependent on testrunner.exe that just calls the testrunner.exe executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run make on a PintOS makefile but I keep getting
In linux make file: I want to run the output program only in case
I have this Makefile and each line run OK separately, but when I do
In OpenSolaris OS, when I run makefile generated by Eclipse CDT on the Linux
I have a simple Makefile: default: @make build @make run build: @javac Test.java >
I want to build and run my project in Netbeans. I generated a simple
This is my makefile: .SILENT: latexargs = -output-directory=temp -interaction=batchmode -file-line-error-style thesis: mktemp latex $(latexargs)
I want to run R (the statistical package) from Perl in RedHat Linux. I
I am using GNU make 3.81. Here is a test makefile that demonstrates the
I have a makefile which does the usual directory creation: $(Release_target_OBJDIR)/%.o: %.cpp mkdir -p

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.