【发布时间】:2017-12-14 20:23:02
【问题描述】:
我正在尝试链接一些目标文件,以便可以在 Codelite IDE 中使用 UnitTest++ 编写测试。神秘的是,tutorial 并没有说明如何使用来自(不同)项目的 .o 文件。
如果我使用命令行,this thread 会告诉我如何操作。但是,我在 Codelite 编辑器中遇到了更多困难。 this other thread 中接受的答案说“[i] 在 codelite 的 IDE 中,这是在链接器的选项文本框中添加的”,但是,我发现情况并非如此。
我在Library Search Path 位置添加这些.o 文件的路径,然后在此下方的Libraries 位置添加各个文件的名称。当我这样做时,我得到/usr/bin/ld: cannot find -l<stuff> 错误。如果我在 Library 位置省略特定文件的名称,我会收到 undefined reference to 错误。
我必须将原始项目编译为库来解决这个问题吗?还是有我看不到的解决方案?我要运行的my_class_test.cpp 文件如下所示:
#include <UnitTest++/UnitTest++.h>
#include "my_class.h"
SUITE(MyClassTest)
{
class MCFixture
{
public:
MyClass me;
MCFixture() : me("a", "b", "c") {};
};
TEST_FIXTURE(MCFixture, ConstructorTest)
{
CHECK_EQUAL(1.0, 1.0);
}
} //SUITE(MyClassTest)
【问题讨论】:
标签: c++ linker object-files codelite