Hello World error: redefinition

86 views
Skip to first unread message

Lari Karam

unread,
Feb 17, 2020, 7:45:08 PM2/17/20
to actor-framework
Hi,
I'm new to CAF and interested in trying it as I'm learning on the actor model.
So I cloned the repo, built it and I tried the hello world example in the documentation and on I get a redefinition error.


In file included from /usr/local/include/caf/message_id.hpp:27,
                 
from /usr/local/include/caf/abstract_channel.hpp:25,
                 
from /usr/local/include/caf/abstract_actor.hpp:30,
                 
from /usr/local/include/caf/all.hpp:23,
                 
from helloworld.cpp:4:
/usr/local/include/caf/detail/type_traits.hpp:276:8: error: redefinition of struct caf::detail::callable_trait<R (C::*)(Ts ...) const>’
 
276 | struct callable_trait<R (C::*)(Ts...) const> : callable_trait<R (Ts...)> {};
     
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/caf/detail/type_traits.hpp:267:8: note: previous definition of struct caf::detail::callable_trait<R (C::*)(Ts ...) const>’
 
267 | struct callable_trait<R (C::*)(Ts...) const noexcept>
     
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/caf/detail/type_traits.hpp:280:8: error: redefinition of struct caf::detail::callable_trait<R (C::*)(Ts ...)>’
 
280 | struct callable_trait<R (C::*)(Ts...)> : callable_trait<R (Ts...)> {};
     
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/caf/detail/type_traits.hpp:272:8: note: previous definition of struct caf::detail::callable_trait<R (C::*)(Ts ...)>’
 
272 | struct callable_trait<R (C::*)(Ts...) noexcept> : callable_trait<R(Ts...)> {};
     
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/caf/detail/type_traits.hpp:288:8: error: redefinition of struct caf::detail::callable_trait<R (*)(Ts ...)>’
 
288 | struct callable_trait<R (*)(Ts...)> : callable_trait<R (Ts...)> {};
     
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/caf/detail/type_traits.hpp:284:8: note: previous definition of struct caf::detail::callable_trait<R (*)(Ts ...)>’
 
284 | struct callable_trait<R (*)(Ts...) noexcept> : callable_trait<R(Ts...)> {};




I'm on linux, OpenSuse Tumbleweed, tried to compile with both with g++ (SUSE Linux) 9.2.1 20190903 [gcc-9-branch revision 275330] and clang version 9.0.1
Any ideas on what I'm missing here?

Thanks

--
Lari

Dominik Charousset

unread,
Feb 18, 2020, 2:11:19 AM2/18/20
to actor-f...@googlegroups.com
Hi and welcome to CAF! :)

Please include your build instructions next time. From the error message, it seems like you’re building against Git master and you’re missing -std=c++17.

Also, I wouldn’t recommend starting with master at the moment. The next version of CAF (0.18) is going to include breaking changes with a redesign of some core components [1]. Consequently, current master is in a somewhat in-between state and deviates in some aspects from the documented behavior. Please consider using the 0.17.4 tag.


Dominik

[1] http://blog.actor-framework.org/2019-11/breaking-changes/

Lari Karam

unread,
Feb 19, 2020, 9:20:39 AM2/19/20
to actor-framework

Thanks for the reply Dominik, and yes I was using the master branch.

So I tried with the 0.17.4 tag, and added the -std=c++17 and still having some issues. I'm definitely doing something wrong on my end.
So here is my build instruction:

./configure --build-static --with-log-level=TRACE--
The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found g++ version 9.2
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.1.1d")  
-- Performing Test OPENSSL_CORRECT_VERSION_NUMBER
-- Performing Test OPENSSL_CORRECT_VERSION_NUMBER - Success
-- Looking for CL_VERSION_2_2
-- Looking for CL_VERSION_2_2 - found
-- Found OpenCL: /usr/lib64/libOpenCL.so (found version "2.2")
-- Pybind submodule not loaded, skip libcaf_python.
-- Found CURL: /usr/lib64/libcurl.so (found version "7.68.0")  
-- Found 129 test suites
-- Set release version for all documentation to 0.17.4.
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.16") found components: doxygen dot
-- Add optional target: doxygen.
--
====================|  Build Summary  |====================

CAF version
:           0.17.4

Build type:            RelWithDebInfo
Build static:          yes
Build static only:     no
Build static runtime:  no
Runtime checks:        no
Log level:             TRACE
With mem. mgmt.:       yes
With exceptions:       yes

Build I/O module:      yes
Build tools:           yes
Build examples:        yes
Build unit tests:      yes
Build OpenCL:          yes
Build OpenSSL:         yes
Build Python:          yes

CXX
:                   /usr/bin/c++
CXXFLAGS
:              -std=c++11 -Wextra -Wall -pedantic -ftemplate-depth=512 -ftemplate-backtrace-limit=0 -Wno-missing-field-initializers -pthread -fPIC -O2 -g -DNDEBUG
LINKER_FLAGS
(shared)  

Source directory:      /Alpha/devbox/libs_repos/actor-framework
Build directory:       /Alpha/devbox/libs_repos/actor-framework/build
Executable path:       /Alpha/devbox/libs_repos/actor-framework/build/bin
Library path:          /Alpha/devbox/libs_repos/actor-framework/build/lib
Install prefix:        /usr/local
Generator:             Unix Makefiles

===========================================================

-- Configuring done
WARNING
: Target "caf-test" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "libcaf_opencl_static" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "libcaf_opencl_shared" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "proper_matrix" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "simple_matrix" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "scan" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "curl_fuse" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "simple_http_broker" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "promises" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "request" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "calculator_behavior" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "integer_stream" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "delegating" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "fixed_stack" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "divider" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "simple_broker" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "group_server" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "dancing_kirby" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "aout" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "hello_world" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "typed_calculator" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "remote_spawn" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "calculator" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "skip_messages" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "dictionary_behavior" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "dining_philosophers" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "custom_types_1" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "custom_types_2" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "ping_pong" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "distributed_calculator" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "cell" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "custom_types_3" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "group_chat" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "caf-vec" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "caf-run" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
WARNING
: Target "caf-generate-rst" requests linking to directory "/Alpha/devbox/libs_repos/actor-framework/libcaf_opencl".  Targets may link only to libraries.  CMake is dropping the item.
-- Generating done
-- Build files have been written to: /Alpha/devbox/libs_repos/actor-framework/build


The Build has some warnings about Targets may link  only to library (but looks like something wrong with my OpenCL library)
The make goes well with only some warnings and the make tests too with the only exception the last one related to OpenCL.
When I compile the helloworld.cpp with this command:
g++ -v -std=c++17 -Wall -Wextra helloworld.cpp -o hw.o

I get the following, (see attached file for more details)...
Using built-in specs.
COLLECT_GCC
=g++
COLLECT_LTO_WRAPPER
=/usr/lib64/gcc/x86_64-suse-linux/9/lto-wrapper
OFFLOAD_TARGET_NAMES
=hsa:nvptx-none
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d --enable-offload-targets=hsa,nvptx-none=/usr/nvptx-none, --without-cuda-driver --disable-werror --with-gxx-include-dir=/usr/include/c++/9 --enable-ssp --disable-libssp --disable-libvtv --disable-cet --disable-libcc1 --enable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-libphobos --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-9 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --with-build-config=bootstrap-lto-lean --enable-link-mutex --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version
9.2.1 20190903 [gcc-9-branch revision 275330] (SUSE Linux)
COLLECT_GCC_OPTIONS
='-v' '-std=c++17' '-Wall' '-Wextra' '-I' '/usr/local/include/' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 
/usr/lib64/gcc/x86_64-suse-linux/9/cc1plus -quiet -v -I /usr/local/include/ -D_GNU_SOURCE helloworld.cpp -quiet -dumpbase helloworld.cpp -mtune=generic -march=x86-64 -auxbase helloworld -Wall -Wextra -std=c++17 -version -o /tmp/ccTNYTkP.s
GNU C
++17 (SUSE Linux) version 9.2.1 20190903 [gcc-9-branch revision 275330] (x86_64-suse-linux)
        compiled
by GNU C version 9.2.1 20190903 [gcc-9-branch revision 275330], GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics
: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory
"/usr/local/include/"
 
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 
/usr/include/c++/9
 
/usr/include/c++/9/x86_64-suse-linux
 
/usr/include/c++/9/backward
 
/usr/lib64/gcc/x86_64-suse-linux/9/include
 
/usr/local/include
 
/usr/lib64/gcc/x86_64-suse-linux/9/include-fixed
 
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/include
 
/usr/include
End of search list.
GNU C
++17 (SUSE Linux) version 9.2.1 20190903 [gcc-9-branch revision 275330] (x86_64-suse-linux)
        compiled
by GNU C version 9.2.1 20190903 [gcc-9-branch revision 275330], GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics
: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 00000000000000000000000000000000
COLLECT_GCC_OPTIONS
='-v' '-std=c++17' '-Wall' '-Wextra' '-I' '/usr/local/include/' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/as -v -I /usr/local/include/ --64 -o /tmp/ccvMq9MP.o /tmp/ccTNYTkP.s
GNU assembler version
2.33.1 (x86_64-suse-linux) using BFD version (GNU Binutils; openSUSE Tumbleweed) 2.33.1.20191023-2
COMPILER_PATH
=/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/
LIBRARY_PATH
=/usr/lib64/gcc/x86_64-suse-linux/9/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/lib/:/usr/lib64/gcc/x86_64-suse-linux/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS
='-v' '-std=c++17' '-Wall' '-Wextra' '-I' '/usr/local/include/' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 
/usr/lib64/gcc/x86_64-suse-linux/9/collect2 -plugin /usr/lib64/gcc/x86_64-suse-linux/9/liblto_plugin.so -plugin-opt=/usr/lib64/gcc/x86_64-suse-linux/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccVNZuET.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/9/crtbegin.o -L/usr/lib64/gcc/x86_64-suse-linux/9 -L/usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/9/../../.. /tmp/ccvMq9MP.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-suse-linux/9/crtend.o /usr/lib64/gcc/x86_64-suse-linux/9/../../../../lib64/crtn.o
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/ccvMq9MP.o: in function `mirror(caf::event_based_actor*)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}::operator()(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
helloworld.cpp:(.text+0x45): undefined reference to `
caf::aout(caf::local_actor*)'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: helloworld.cpp:(.text+0x70): undefined reference to `std::endl(caf::actor_ostream&)'


...
...

/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/ccvMq9MP.o: in function `caf::detail::type_erased_value_impl<caf::error>::type_erased_value_impl<caf::error const&>(caf::error const&)':
helloworld.cpp:(.text._ZN3caf6detail22type_erased_value_implINS_5errorEEC2IJRKS2_EEEDpOT_[_ZN3caf6detail22type_erased_value_implINS_5errorEEC5IJRKS2_EEEDpOT_]+0x44): undefined reference to `
caf::error::error(caf::error const&)'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: helloworld.cpp:(.text._ZN3caf6detail22type_erased_value_implINS_5errorEEC2IJRKS2_EEEDpOT_[_ZN3caf6detail22type_erased_value_implINS_5errorEEC5IJRKS2_EEEDpOT_]+0x55): undefined reference to `caf::type_erased_value::~type_erased_value()'

collect2
: error: ld returned 1 exit status




The installation is in /usr/local/ the default.
I tried forcing $LD_LIBRARY_PATH, $CPP_INCLUDE_PATH
same results...
Any thoughts?
thanks & sorry for my noob questions

--
lari
gpp_logFile.txt

Dominik Charousset

unread,
Feb 19, 2020, 10:33:54 AM2/19/20
to actor-f...@googlegroups.com
> g++ -v -std=c++17 -Wall -Wextra helloworld.cpp -o hw.o

This misses paths to headers (-I<path>), paths to shared libraries (-L<path>), and link dependencies (-l<lib>).

If you’ve installed CAF to default directory, -L and -I become obsolete, but usually, you’ll have at least something like:

g++ -std=c++17 helloworld.cpp -o helloworld -lcaf_core

If you’re loading the I/O module, you’ll also ned caf_io.

Btw, rather than fiddling with the command line, I strongly suggest writing a minimal CMake scaffold instead. :)

> The installation is in /usr/local/ the default.
> I tried forcing $LD_LIBRARY_PATH, $CPP_INCLUDE_PATH

LD_LIBRARY_PATH is about finding shared objects at runtime. It’s not relevant during compiling / linking.

> Any thoughts?
> thanks & sorry for my noob questions


No worries, we’ve all been there.

Dominik

Lari Karam

unread,
Feb 19, 2020, 10:53:12 PM2/19/20
to actor-framework
Thank you for the details! :)
It worked!
I'll have a go and play around with the framework!

Cheers!
--
Lari
Reply all
Reply to author
Forward
0 new messages