Skip to content

Failed to compile C++ LibTorch VAD example #598

@fred-rabelo

Description

@fred-rabelo

I am not a very experienced programmer, so excuse me for any simple confusion.
(running on Windows 11-64x, forgot to say)

I am trying to compile the C++ Libtorch example but running on few errors:

When i run the standard compilation line from the the readme, corrected for the location of my libtorch:

g++ main.cc silero_torch.cc -I ../../../libtorch/include/ -I ../../../libtorch/include/torch/csrc/api/include -L ../../../libtorch/lib/ -ltorch -ltorch_cpu -lc10 -Wl,-rpath,../../../libtorch/lib/ -o silero -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0

i get the following error:

At line:1 char:166
 ... lude -L ../../../libtorch/lib/ -ltorch -ltorch_cpu -lc10 -Wl,-rpath,. ...
                                                                 ~
Missing argument in parameter list.

At line:1 char:173
 ...  ../../../libtorch/lib/ -ltorch -ltorch_cpu -lc10 -Wl,-rpath,../../.. ...
                                                                 ~
Missing argument in parameter list.
     CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
     FullyQualifiedErrorId : MissingArgument

I don´t understand what argument is missing there. Any insights?

removing the Option -Wl,-rapth, :

g++ main.cc silero_torch.cc -I ../../../libtorch/include/ -I ../../../libtorch/include/torch/csrc/api/include -L ../../../libtorch/lib/ -ltorch -ltorch_cpu -lc10 -o silero -std=c++14 -D_GLIBCXX_USE_CXX11_ABI=0

it executes but returns basically the following errors:

../../../libtorch/include/torch/csrc/jit/ir/ir.h: At global scope:
../../../libtorch/include/torch/csrc/jit/ir/ir.h:302:42: error: function 'std::shared_ptr<torch::jit::Wrap<torch::jit::Value> > torch::jit::Value::wrap()' definition is marked dllimport
  302 |   TORCH_API std::shared_ptr<Wrap<Value>> wrap() {
      |                                          ^~~~
../../../libtorch/include/torch/csrc/jit/ir/ir.h:1138:42: error: function 'std::shared_ptr<torch::jit::Wrap<torch::jit::Block> > torch::jit::Block::wrap()' definition is marked dllimport
 1138 |   TORCH_API std::shared_ptr<Wrap<Block>> wrap() {
      |                                          ^~~~

and:

../../../libtorch/include/c10/macros/Macros.h:432:5: error: '__assert_fail' was not declared in this scope; did you mean '__fastfail'?
  432 |     __assert_fail(                                                       \
      |     ^~~~~~~~~~~~~

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions