-1

I was trying to link the external library https://github.com/bk192077/struct_mapping. I have done all necessary steps given in the to do section but still when I include that into my code it gives me error.

$ g++ test test.cpp
test.cpp:1:10: fatal error: struct_mapping/struct_mapping.h: No such file or directory
    1 | #include "struct_mapping/struct_mapping.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

If anybody know how to handle this. It will be great. And also I do not know what is CMake. As I am very beginner in coding.

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Amol
  • 1
  • Hey Amol, would it be possible for you to include the CMakeList.txt file you are currently using to link with this external Libraby? As for what CMake is, CMake automates the creation of Makefiles. What are Makefiles? Makefiles are configuration files used in conjunction with the "make" utility to automate the process of building software projects. They are more useful when dealing with multiple source files in more complex projects. – Michael Williamson Aug 30 '23 at 04:51
  • 1
    The problem you have isn't about linking, it's about finding the header file at compilation. How do you search for and add your library? – Some programmer dude Aug 30 '23 at 04:52
  • 1
    You don't even show us any commands related to CMake. The command you show is an attempt to build the program on our own, without the help of CMake or any generated project or build system. – Some programmer dude Aug 30 '23 at 04:53
  • 1
    Assuming a default git install, the simple answer would be `g++ -I ~/struct_mapping/include test test.cpp`. Change the `~/struct_mapping` part to match wherever you installed the project to. Note this suggestion has nothing to do with CMake. – Ken Y-N Aug 30 '23 at 04:55
  • If you want to start with CMake and learn it, why not start with [the official tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)? There are also plenty of other tutorials online. Unfortunately this is *not* a tutorial site, nor a tutorial-finder site really. Use your favorite search engine for finding tutorials. – Some programmer dude Aug 30 '23 at 04:58
  • @Someprogrammerdude I do not know how to relate that Cmake file and my prooject. I thought it works when I follow instructions given in github. And execute my project directly using compile command. But I do not know how to link them. And I did not found any supporting document for it – Amol Aug 30 '23 at 06:32
  • @KenY-N Hey it worked when I execute using your command but can you explain how it worked? – Amol Aug 30 '23 at 06:45
  • [This answer describes the command line options and links to the official documentation](https://stackoverflow.com/a/6141166/1270789). – Ken Y-N Aug 30 '23 at 08:02
  • Research, research and more research. A professional developer is expected to be able to do their own research. I added a link to one tutorial, and you have many more a quick search engine visit away. Don't expect to be spoon fed everything you need to know. – Some programmer dude Aug 30 '23 at 10:06

0 Answers0