Skip to content

Commit

Permalink
Merge pull request #134 from ken4647/dev
Browse files Browse the repository at this point in the history
add hello_world example for cpp
  • Loading branch information
Harris-pku authored Jul 5, 2024
2 parents 2df4fb5 + e2de1bd commit 3be0dc6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions apps/c/cpp_helloworld/axbuild.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARCH ?= x86_64
C_COMPILER := $(shell which $(CC))
CXX_COMPILER := $(shell which $(CC))
AR := $(shell which $(AR))
RANLIB := $(shell which $(RANLIB))
CROSS_COMPILE_PATH := $(shell dirname $(C_COMPILER))/..

app-objs := main.o

$(APP)/$(app-objs): $(APP)/axbuild.mk
$(CXX_COMPILER) -c -o $(app-objs) $(APP)/main.cpp
$(LD) -o $(app-objs) -nostdlib -static -no-pie -r -e main \
$(app-objs) \
$(CROSS_COMPILE_PATH)/*-linux-musl/lib/libstdc++.a \
$(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc_eh.a

clean_c::
rm -rf $(APP)/$(app-objs)

.PHONY: $(APP)/$(app-objs) clean_c
6 changes: 6 additions & 0 deletions apps/c/cpp_helloworld/features.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
alloc
paging
irq
multitask
fs
random-hw
12 changes: 12 additions & 0 deletions apps/c/cpp_helloworld/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>

using namespace std;

// This is a dummy function to avoid linker errors as this example should be a static executable.
void* __dso_handle = NULL;

int main(int argc, char* argv[]) {
cout << "Hello, wolrd!" << endl;
return 0;
}

0 comments on commit 3be0dc6

Please sign in to comment.