Skip to content

Instantly share code, notes, and snippets.

@khws4v1
Created May 13, 2017 13:04
Show Gist options
  • Select an option

  • Save khws4v1/a37d68b48784d98d37be0061bfc7212f to your computer and use it in GitHub Desktop.

Select an option

Save khws4v1/a37d68b48784d98d37be0061bfc7212f to your computer and use it in GitHub Desktop.
Makefile-example
#include <stdio.h>
void hello_c(void)
{
puts("Hello world in C.");
}
#include <iostream>
void hello_cplusplus()
{
std::cout << "Hello world in C++." << std::endl;
}
extern "C" void hello_c(void);
void hello_cplusplus();
int main()
{
hello_c();
hello_cplusplus();
return 0;
}
CC = gcc
CFLAGS = -std=c99
CXX = g++
CPPFLAGS = -std=c++11
TARGET = example
SRCS = \
hello-c.c \
hello-cplusplus.cpp \
main.cpp \
OBJS = $(addsuffix .o, $(basename $(SRCS)))
$(TARGET): $(OBJS)
$(CXX) $^ -o $@
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS)
CC = gcc
CFLAGS = -std=c99
CXX = g++
CXXFLAGS = -std=c++11
TARGET = example
SRCS = \
hello-c.c \
hello-cplusplus.cpp \
main.cpp \
OBJS = $(addsuffix .o, $(basename $(SRCS)))
$(TARGET): $(OBJS)
$(CXX) $^ -o $@
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment