【发布时间】:2014-10-07 04:38:02
【问题描述】:
我有 main.cpp,从 io.c 链接测试函数
#include <iostream>
#include "io.h"
int main(int argc, char **argv) {
test();
return 0;
}
io.c:
#include <stdio.h>
#include "io.h"
void test() {
printf("hee");
}
我将 CMakeLists.txt 配置如下:
project(test)
set(MyProjectSources io.c io.h main.cpp )
add_executable(test ${MyProjectSources})
但是,当我构建项目时,出现未定义引用的错误。 请帮我。
PS:如果 main.cpp 引用了 l1.h 和 l2.h 等 2 个库。如何将这些链接到 main.cpp?
【问题讨论】:
-
如果不发布实际错误,我们无能为力。另外:您可能不想将 io.h(头文件!)添加到源列表中。
标签: reference ubuntu-12.04 undefined-reference kdevelop printf-debugging