Skip to content

Commit 3be0dc6

Browse files
authored
Merge pull request #134 from ken4647/dev
add hello_world example for cpp
2 parents 2df4fb5 + e2de1bd commit 3be0dc6

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-0
lines changed

apps/c/cpp_helloworld/axbuild.mk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARCH ?= x86_64
2+
C_COMPILER := $(shell which $(CC))
3+
CXX_COMPILER := $(shell which $(CC))
4+
AR := $(shell which $(AR))
5+
RANLIB := $(shell which $(RANLIB))
6+
CROSS_COMPILE_PATH := $(shell dirname $(C_COMPILER))/..
7+
8+
app-objs := main.o
9+
10+
$(APP)/$(app-objs): $(APP)/axbuild.mk
11+
$(CXX_COMPILER) -c -o $(app-objs) $(APP)/main.cpp
12+
$(LD) -o $(app-objs) -nostdlib -static -no-pie -r -e main \
13+
$(app-objs) \
14+
$(CROSS_COMPILE_PATH)/*-linux-musl/lib/libstdc++.a \
15+
$(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc_eh.a
16+
17+
clean_c::
18+
rm -rf $(APP)/$(app-objs)
19+
20+
.PHONY: $(APP)/$(app-objs) clean_c

apps/c/cpp_helloworld/features.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
alloc
2+
paging
3+
irq
4+
multitask
5+
fs
6+
random-hw

apps/c/cpp_helloworld/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
// This is a dummy function to avoid linker errors as this example should be a static executable.
6+
void* __dso_handle = NULL;
7+
8+
int main(int argc, char* argv[]) {
9+
cout << "Hello, wolrd!" << endl;
10+
return 0;
11+
}
12+

0 commit comments

Comments
 (0)