Netbeans:如何包括其他c ++静态库项目? [英] Netbeans: how to include other c++ static library project?

查看:735
本文介绍了Netbeans:如何包括其他c ++静态库项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢c ++,现在正在使用Netbeans。



我设法创建一个Sign.h和Sign.cpp包含一个工作类签名
我将这些添加到控制台项目,它的工作原理:

  #include< iostream& 
#include< ostream>
#includeSign.h

int main()
{
Sign sign = Sign :: parse(b);
std :: cout<< sign.toString()<< < sign.getValue()<<\\\
;但是,我想创建一个静态库,其中包含
}


$ b > Sign
类,因此我创建了一个静态库并添加了 Sign.cpp Sign.h 到它。现在的问题是,我似乎不能让我的Sign类包含在主控制台程序中。



我在 Options => Build => Linker =>库,并将其添加到必需的项目。但我不能使用 #include< Sign> #include< Sign.h> p>

我在这里缺少什么?

解决方案

图书馆。库文件(.lib在windows上,.a在linux上)和包含文件(.h文件)。



Options => Build => Linker => Libraries仅用于库文件。你还需要在File => Project Properties =>
下设置包含路径。Build => C ++ Compiler => General => Include Directories


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

这篇关于Netbeans:如何包括其他c ++静态库项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆