Updated Makefiles

This commit is contained in:
2025-05-12 22:05:38 +02:00
parent e84560fa25
commit e5bad0c642
7 changed files with 108 additions and 0 deletions

35
Task_3/Task_3.1/Makefile Normal file
View File

@@ -0,0 +1,35 @@
# Syntax
# <target>: <dependencies>
# <command>
# ...
# variables
CXX = g++
CXXFLAGS = -Wall -std=c++11
# standard rule
all: main
# creating main from main.o and hello_world.a
# $@ = target
# $^ = dependencies
main: main.o hello_world.a
$(CXX) $(CXXFLAGS) -o $@ $^
# creating archive out of object
# % = filename without ending
# $@ = target
# $^ = dependencies
%.a: %.o
ar rcs $@ $^
# creating object out of cpp
# % = filename without ending
# $@ = target
# $^ = dependencies
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $^
# remove all objects and archives
clean:
rm -f *.o *.a main

View File

@@ -0,0 +1,9 @@
#include <iostream>
#include "hello_world.h"
void hello() {
std::cout << "Hello World" << std::endl;
}
// g++ -c hello_world.cpp -o hello_world.o
// ar rcs hello_world.a hello_world.o

View File

@@ -0,0 +1,6 @@
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
void hello(); // Deklaration der Funktion
#endif

7
Task_3/Task_3.1/main.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include <iostream>
#include "hello_world.h"
int main(){
hello();
return 0;
}