简体   繁体   中英

Netbeans: how to include other c++ static library project?

I am really new to c++ and am using Netbeans for now.

I managed to create a Sign.h and Sign.cpp containing a working class Sign . I added these to a Console Project and it works great:

  #include <iostream>
  #include <ostream>
  #include "Sign.h"

  int main()
  {
      Sign sign = Sign::parse("b");
      std::cout << sign.toString() << " " << sign.getValue() <<"\n";
  }

However, I want to create a static library containing the Sign class, so I created a static library and added Sign.cpp and Sign.h to it. The problem now is, that I can't seem to get my Sign class to be included in the main console program.

I added the library in Options => Build => Linker => Libraries , and added it to the required projects . However I can't use #include <Sign> or #include <Sign.h> .

What am I missing here?

You need two files from a library. The library file (.lib on windows, .a on linux) and the include file (.h files).

The Options => Build => Linker => Libraries is only for the library file. You also need to set the path for the includes under File => Project Properties => Build => C++ Compiler => General => Include Directories

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM