Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hello_world example for cpp #134

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

Loading