从VS2015中的大多数C ++项目创建库 [英] Creating a library from most of my C++ project in VS2015

查看:77
本文介绍了从VS2015中的大多数C ++项目创建库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的大部分项目都是由一个"数字计算器"组成的。具有许多公共方法的类,其源代码位于多个.cpp文件和单个.h头文件中。用户界面View类创建了一个cruncher实例。


我想保留当前项目,但也为想要写的人创建一个cruncher库他们自己的用户界面。


我创建了没有预编译听众的.lib项目,并添加了所有相应的文件,但是遇到了stdafx.h问题。 #include位于每个源文件的顶部,不能被#ifndef _LIB / #endif包围。


我添加了一个新的"dummy" lib项目中的stdafx.h但编译器无法看到它。解决方案资源管理器清楚地知道它在哪里,但编译器找不到它。


我该怎么做?


非常感谢提前。

解决方案

在库源文件中包含stdafx.h应该与您创建可供其他人使用的静态库的能力无关使用相关的头文件来声明库中包含的函数。


我建议你从项目中删除虚拟stdafx.h文件。


The bulk of my project consists of a single "number cruncher" class with many public methods, the source for which resides in multiple .cpp files and a single .h header file. The user interface View class creates one instance of the cruncher.

I would like to retain the current project as it is, but also create a library of the cruncher for people who want to write their own user interfaces.

I have created the .lib project without precompiled hearders, and added all the appropriate files, but have run into the stdafx.h problem. The #include is at the top of every source file and cannot be surrounded by #ifndef _LIB / #endif.

I have added a new "dummy" stdafx.h in the lib project but the compiler cannot see it. Solution explorer clearly knows where it is, but the compiler cannot find it.

What do I have to do ?

Many thanks in advance.

解决方案

Inclusion of stdafx.h in library source files should have no bearing on your ability to create a static library that can be used by others with a related header file that declares the functions contained in the library.

I suggest you remove the dummy stdafx.h file from the project.


这篇关于从VS2015中的大多数C ++项目创建库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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