1

Currently my project just has one BookPrinter.cpp file and the CMakeList.txt in its directory contains

add_executable(book_printer
    BookPrinter.cpp
)

target_link_libraries(book_printer
    ${MD_API_LIBRARIES}
    rt
    z
)

Now I want to add a new class "MyBookWrapper" with MyBookWrapper.h and MyBookWrapper.cpp in the same directory. I have include BookWrapper.h in my BookPrinter.cpp.

but when I compile I got this error

BookPrinter.cpp:blah blah blha incomprehensible code : undefined reference to `MyBookWrapper::Refresh()'
collect2: error: ld returned 1 exit status

What should I add to include this new MyBookWrapper?

CuriousMind
  • 15,168
  • 20
  • 82
  • 120

1 Answers1

2

Well, the first thing you should do is add MyBookWrapper.cpp to your add_executable statement.

What you have there is a linker error meaning that it can't locate the code for your new class, it has nothing to do with the header file.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953