Skip to content

Question: how to use with multiple files and not get linker errors #16

Description

@crucialfelix

I'm trying to write classes that have VarSignal members. My problem is with the REACTIVE_DOMAIN macro.

When I include these classes I get linker errors because there is now a duplicate symbol _D_initializer_ in each .o file.

The examples all show one page of code in a single .cpp file (and no header files)

//  DataSource.hpp
#ifndef DataSource_hpp
#define DataSource_hpp

#include "react/Domain.h"
#include "react/Signal.h"
#include "react/Event.h"

REACTIVE_DOMAIN(D, react::sequential)

class DataSource {
 public:
    react::VarSignal<D, int> numDimensions = react::MakeVar<D>(0);
    react::EventSource<D>  didLoad         = react::MakeEventSource<D>();
};

#endif /* DataSource_hpp */
// ofApp.cpp
#pragma once

#import "DataSource.hpp"

class ofApp {
 public:
  // ...

 private:
  DataSource dataSource;
};

The linker now fails because D has been defined twice.

duplicate symbol _D_initializer_ in:
    /Users/crucial/Library/Developer/Xcode/DerivedData/PlaySPLOM-gwpsbmgveykcqsheakzuilcqldtb/Build/Intermediates/PlaySPLOM.build/Debug/PlaySPLOM.build/Objects-normal/x86_64/DataSource.o
    /Users/crucial/Library/Developer/Xcode/DerivedData/PlaySPLOM-gwpsbmgveykcqsheakzuilcqldtb/Build/Intermediates/PlaySPLOM.build/Debug/PlaySPLOM.build/Objects-normal/x86_64/ofApp.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Furthermore, should all classes in this application use the same D ? Or should each create their own ? (with a unique name?)
Where ideally should the domain be declared ? I tried

I realize the library is experimental, but I quite like the syntax and was hoping to get this to work for an openFrameworks data visualization/sonification project.

thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions