Add example program with dockerfile
This commit is contained in:
parent
fa82d57d10
commit
f5cac6d77c
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM gcc:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY bin/hello_world /app/
|
||||
|
||||
CMD ["bin/hello_world"]
|
27
makefile
Normal file
27
makefile
Normal file
@ -0,0 +1,27 @@
|
||||
# Makefile for hello.c
|
||||
|
||||
CC = g++ # C compiler
|
||||
CFLAGS = -O2 # Compiler flags (optimization level)
|
||||
|
||||
SRC_DIR = src
|
||||
BUILD_DIR = build
|
||||
BIN_DIR = bin
|
||||
EXECUTABLE = Test
|
||||
|
||||
# Create directories
|
||||
$(shell mkdir -p $(BUILD_DIR) $(BIN_DIR))
|
||||
|
||||
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
OBJECT_FILES = $(SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/$(EXECUTABLE): $(OBJECT_FILES)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
run:
|
||||
$(BIN_DIR)/$(EXECUTABLE)
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD_DIR)/*.o $(BIN_DIR)/*
|
7
src/main.cpp
Normal file
7
src/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user