问题描述
我对 C++ 真的很陌生,现在正在使用 Netbeans.
I am really new to c++ and am using Netbeans for now.
我设法创建了一个包含工作类 Sign 的 Sign.h 和 Sign.cpp.我将这些添加到控制台项目中,效果很好:
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() <<"
";
}
但是,我想创建一个包含 Sign 类的静态库,所以我创建了一个静态库并添加了 Sign.cpp 和 Sign.h 到它.现在的问题是,我似乎无法将 Sign 类包含在主控制台程序中.
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.
我在 Options => 中添加了库构建 =>链接器 =>库,并将其添加到所需项目.但是我不能使用 #include 或 #include .
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>.
我在这里遗漏了什么?
推荐答案
您需要一个库中的两个文件.库文件(Windows 上的 .lib,Linux 上的 .a)和包含文件(.h 文件).
You need two files from a library. The library file (.lib on windows, .a on linux) and the include file (.h files).
选项 => 构建 => 链接器 => 库仅用于库文件.您还需要在 File => Project Properties => 下设置包含的路径构建 => C++ 编译器 => 通用 => 包含目录
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++ 静态库项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)