admin管理员组

文章数量:1302979

Following their template, I have:

conan new cmake_lib -d name=mlpackmsvc -d requires=mlpack/4.4.0

followed by conan build .

This ends up with error:

C:\test\src\mlpackmsvc.cpp(3,10): error C1083: Cannot open include file: 'mlpack.h': No such file or directory [C:\test\build\mlpackmsvc.vcxproj]
ERROR: conanfile.py (mlpackmsvc/0.1): Error in build() method, line 48
        cmake.build()
        ConanException: Error 1 while executing

My default profile is

[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=194
os=Windows

How can this error be fixed?

Following their template, I have:

conan new cmake_lib -d name=mlpackmsvc -d requires=mlpack/4.4.0

followed by conan build .

This ends up with error:

C:\test\src\mlpackmsvc.cpp(3,10): error C1083: Cannot open include file: 'mlpack.h': No such file or directory [C:\test\build\mlpackmsvc.vcxproj]
ERROR: conanfile.py (mlpackmsvc/0.1): Error in build() method, line 48
        cmake.build()
        ConanException: Error 1 while executing

My default profile is

[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=194
os=Windows

How can this error be fixed?

Share asked Feb 11 at 4:59 One_Cable5781One_Cable5781 655 bronze badges 3
  • 1 Is mlpack.h a file that actually exist in that package? With that path? The conan new template doesn't generate the correct #include or function call, it just takes the -d requires=pkg/version and generates a placeholder #include "pkg.h" and a function call pkg();. This works if the other pkg was also generated with another conan new cmake_lib -d name=pkg, but it won't work for any random third party library. So you need to change the header name to something that really exists in mlpack, and same for function call. – drodri Commented Feb 11 at 8:30
  • You are absolutely correct. The header file is mlpack.hpp mlpack./doc/quickstart/cpp.html I will fix that and hopefully the error goes away. Thank you for your help! – One_Cable5781 Commented Feb 11 at 8:59
  • 1 I will add then this comment as a response – drodri Commented Feb 12 at 9:14
Add a comment  | 

1 Answer 1

Reset to default 1

The conan new templates doesn't generate the correct #include or function calls for any arbitrary dependency. I t just takes the -d requires=pkg/version argument and generates a placeholder #include "pkg.h" and a function call pkg();.

This works if the other package called pkg was also generated with another conan new cmake_lib -d name=pkg command , but it won't work for any random third party library.

So you need to change the placeholders header name and function call to something that really exists in mlpack.

本文标签: cmakeconan new template project build fails with header file not foundStack Overflow