Created
May 13, 2017 13:04
-
-
Save khws4v1/a37d68b48784d98d37be0061bfc7212f to your computer and use it in GitHub Desktop.
Makefile-example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void hello_c(void) | |
| { | |
| puts("Hello world in C."); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| void hello_cplusplus() | |
| { | |
| std::cout << "Hello world in C++." << std::endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern "C" void hello_c(void); | |
| void hello_cplusplus(); | |
| int main() | |
| { | |
| hello_c(); | |
| hello_cplusplus(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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