I have built a shared library under Eclipse/CDT in C++. To manage my projects tests, I would like to have in the same project the library and an executable for running tests on the library.
How can I do that please ?
I have built a shared library under Eclipse/CDT in C++. To manage my projects tests, I would like to have in the same project the library and an executable for running tests on the library.
How can I do that please ?
对于库本身,我有标准的构建设置:一个Debug和一个Release目标,带有-fPIC编译选项、工件类型Shared Library、扩展名so和前缀lib以及-share链接器选项。
对于测试程序,我在同一个项目中添加了一个main.cpp文件:
#ifdef TEST_
#include <cstdlib>
#include <iostream>
#include "config.h"
using namespace std;
int main(int argc, char **argv) {
cout << "Test for project utils" << endl;
return 0;
}
#endif /* TEST_ */
我添加了一个Test从其中复制的特定目标,DEBUG并适用于标准可执行构建设置:禁止-fPIC编译选项、添加-D TEST_、修改工件类型为、禁止Executable扩展名so和前缀lib、禁止-share链接器选项。
现在,只要像往常一样构建 Debug、Release 和 Test,什么都可以独立完成。Test目标可以很容易地更改为 sayTest-Debug和,以便在Test-Release安装后立即运行库自检。