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

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

Open
crucialfelix opened this issue Oct 12, 2015 · 0 comments
Open

Comments

@crucialfelix
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant