Menu

"multiple definition of" in rxcpp linking

mariusz_w
2015-03-31
2015-03-31
  • mariusz_w

    mariusz_w - 2015-03-31

    Hi,
    1. I tried to cmpile rective extensions (rxcpp) https://github.com/Reactive-Extensions/RxCpp in mingw from msys2.
    2. I use build command: cmake -G"Unix Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -B. ../CMake
    3. during linking (in make phase) one of test program I got a lot of multiple definition
    4. In ubuntu 14.04 (gcc 4.8) linking works
    5. Other test programs from rxcpp link ok
    6. Maybe someone have idea what to do

    Regards,
    Mariusz

    [ 95%] Building CXX object CMakeFiles/rxcppv2_test.dir/D_/tmp/RX/RxCpp/Rx/v2/test/operators/window.cpp.obj
    [ 97%] Building CXX object CMakeFiles/rxcppv2_test.dir/D_/tmp/RX/RxCpp/Rx/v2/test/operators/zip.1.cpp.obj
    [100%] Building CXX object CMakeFiles/rxcppv2_test.dir/D_/tmp/RX/RxCpp/Rx/v2/test/operators/zip.2.cpp.obj
    Linking CXX executable rxcppv2_test.exe
    CMakeFiles/rxcppv2_test.dir/objects.a(subscription.cpp.obj):subscription.cpp:(.bss+0x0): multiple definition of .weak.__ZGVN5rxcpp10schedulers9immediate8instanceE.__ZN5rxcpp12subscription23base_subscription_state11unsubscribeEv' CMakeFiles/rxcppv2_test.dir/objects.a(observer.cpp.obj):observer.cpp:(.bss+0x0): first defined here CMakeFiles/rxcppv2_test.dir/objects.a(subscription.cpp.obj):subscription.cpp:(.bss+0x8): multiple definition of.weak.ZGVN5rxcpp10schedulers10event_loop8instanceE.ZN5rxcpp12subscription23base_subscription_state11unsubscribeEv'
    CMakeFiles/rxcppv2_test.dir/objects.a(observer.cpp.obj):observer.cpp:(.bss+0x8): first defined here
    CMakeFiles/rxcppv2_test.dir/objects.a(subscription.cpp.obj):subscription.cpp:(.bss+0x10): multiple definition of .weak.__ZGVN5rxcpp10schedulers10new_thread8instanceE.__ZN5rxcpp12subscription23base_subscription_state11unsubscribeEv' CMakeFiles/rxcppv2_test.dir/objects.a(observer.cpp.obj):observer.cpp:(.bss+0x10): first defined here CMakeFiles/rxcppv2_test.dir/objects.a(subscription.cpp.obj):subscription.cpp:(.bss+0x18): multiple definition of.weak.ZGVN5rxcpp10schedulers14current_thread8instanceE.ZN5rxcpp12subscription23base_subscription_state11unsubscribeEv'
    CMakeFiles/rxcppv2_test.dir/objects.a(observer.cpp.obj):observer.cpp:(.bss+0x18): first defined here
    CMakeFiles/rxcppv2_test.dir/objects.a(subscription.cpp.obj):subscription.cpp:(.bss+0x20): multiple definition of `.weak._

    ///
    $ gcc -v
    Using built-in specs.
    COLLECT_GCC=D:\msys2_64\mingw32\bin\gcc.exe
    COLLECT_LTO_WRAPPER=D:/msys2_64/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/lto-wrapper.exe
    Target: i686-w64-mingw32
    Configured with: ../gcc-4.9.2/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --with-gxx-include-dir=/mingw32/include/c++/4.9.2 --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-cloog-backend=isl --enable-version-specific-runtime-libs --disable-cloog-version-check --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-cloog=/mingw32 --with-pkgversion='Rev5, Built by MSYS2 project' --with-bugurl=http://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2
    Thread model: posix
    gcc version 4.9.2 (Rev5, Built by MSYS2 project)

    ///

     
  • rubenvb

    rubenvb - 2015-03-31

    For MSYS, you'll need

    cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -B. ../CMake
    

    The compilers (gcc and g++) will be automatically found, no need to specify them.

    Unfortunately, I can't seem to get it to work on my Arch Linux install nor my MSYS2 and run into this error:

    [...]/RxCpp/Rx/v2/test/test.cpp:11:21: fatal error: catch.hpp: No such file or directory
     #include "catch.hpp"
                             ^
    
     
  • mariusz_w

    mariusz_w - 2015-03-31

    Thank You for answer.
    I check this new cmake call but link error is the same:(
    The compilers are detected as You describe.

    To initialize catch.hpp You need
    git clone --recursive <url>
    or
    git submodule init and then git submodule update
    as described here: https://rxcpp.codeplex.com/discussions/552510#post1275356

    Regards,
    Mariusz

     

Log in to post a comment.