Hello, World Program!

35 views
Skip to first unread message

Tanzeela Younas

unread,
Sep 24, 2021, 4:57:23 AM9/24/21
to actor-framework
I am new to CAF and eagerly wants to learn it.
I have Installed CMAKE, cloned and build CAF. Its done

Now in the documentation


There is a hello world program .Can anyone please guide me how to compile and run that Program.
Thanks In Advance!

Andrey Deykunov

unread,
Sep 25, 2021, 1:11:18 AM9/25/21
to actor-framework

Hi,

I'm not referring to CAF for a long time, but I'll try to help you. This is a simple Makefile to build your test programs:

CC=clang++
INCLUDE=/your/path/to/caf/inludes
LIBS=/your/path/to/caf/libs
CFLAGS=-c -DDEBUG -g -std=c++17 -stdlib=libc++ -Wextra -Wall -pedantic $(INCLUDE)
LDFLAGS=-lpthread -lc++ -lc++abi -lcaf_core

SOURCES=$(shell echo *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
        EXECUTABLE=name_of_your_elf

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
                $(CC) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
                $(CC) $(CFLAGS) $< -o $@

clean:
                rm -rf $(EXECUTABLE) *.o

If you already built CAF, set up both INCLUDE and LIBS variables, and of course a name of your executable file (EXECUTABLE). Then run make all in the directory containing your source file (main.cpp for example). Replace the CC value with gcc instead of clang if you need, you can play with the compilation flags as well, for example, remove libc++ library or just install llvm (https://apt.llvm.org/).

Anyway, you need to learn more about working with compilers, linking and libraries in c++ (http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html)

Thanks,
Andrey






пятница, 24 сентября 2021 г. в 11:57:23 UTC+3, tanzeel...@gmail.com:

Dominik Charousset

unread,
Sep 27, 2021, 2:05:04 AM9/27/21
to actor-f...@googlegroups.com
I think the Makefile is a good place to get started.

Once your project increases in scope, I’d also recommend getting familiar with CMake. CAF installs a CMake package file, so you can do `find_package(CAF COMPONENTS core io REQUIRED)` and then link to the imported targets CAF::core and CAF::io.


Best,
Dominik

--
You received this message because you are subscribed to the Google Groups "actor-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actor-framewo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/f47a2d1d-c99b-487f-b389-e3391a2a4f73n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages