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?
NetBeans C/C support lets you create C and C Application and Library projects with generated makefiles, as well as C and C++ projects with existing sources. You can build, run, and debug your project on the local host (the system from which you started the IDE) or on a remote host running a UNIX® operating system.
Static libraries are created by copying all necessary library modules used in a program into the final executable image. The linker links static libraries as a last step in the compilation process. An executable is created by resolving external references, combining the library routines with program code.
Static libraries belong next to their corresponding dynamic libraries, and in accordance with the FHS. Keep in mind that static libraries are usually only needed to build software, not run it.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With