google / sling

SLING - A natural language frame semantics parser
Apache License 2.0
1.93k stars 268 forks source link

cannot define or redeclare 'registry_' because namespace 'syntaxnet' does not enclose namespace 'Component<syntaxnet::dragnn::Component>' #112

Closed zuzana closed 6 years ago

zuzana commented 6 years ago

I'm trying to run training script from README:

./sling/nlp/parser/tools/train.sh --report_every=500 --train_steps=1000

However I'm getting following error:

Writing command to local/sempar/out/command
INFO: Found 1 target...
ERROR: sling/third_party/syntaxnet/BUILD:26:1: C++ compilation of rule '//third_party/syntaxnet:syntaxnet' failed (Exit 1).
third_party/syntaxnet/dragnn/core/component_registry.cc:21:1: error: cannot define or redeclare 'registry_' here because namespace 'syntaxnet' does not enclose namespace 'Component<syntaxnet::dragnn::Component>'
REGISTER_COMPONENT_REGISTRY("DRAGNN Component", dragnn::Component);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./sling/base/registry.h:253:52: note: expanded from macro 'REGISTER_COMPONENT_REGISTRY'
  classname::Registry sling::Component<classname>::registry_ = { \
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
1 error generated.
Target //sling/nlp/parser/trainer:generate-master-spec failed to build

Do you see anything obvious I could fix to make it work? Thanks.

ringgaard commented 6 years ago

What compiler and platform are you using?

zuzana commented 6 years ago

I'm trying to build in on Mac OS with gcc 4.2.1. However I have basic experience with C++ that's why I'm trying to see if it's sth. trivial that I'm not getting or I should search more.

zuzana commented 6 years ago

ok, it was trivial in the end:

in _third_party/syntaxnet/dragnn/core/componentregistry.cc I just commented out namespace syntaxnet and added it explicitly as part of argument and then it worked alright (meaning syntaxnet was build)

#include "dragnn/core/component_registry.h"

// namespace syntaxnet {

// Class registry for DRAGNN components.
REGISTER_COMPONENT_REGISTRY("DRAGNN Component", syntaxnet::dragnn::Component);

// }  // namespace syntaxnet