-1

I have main.cpp, linking test function from 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");
}

and I configure CMakeLists.txt as following:

project(test)
set(MyProjectSources io.c io.h main.cpp )
add_executable(test ${MyProjectSources})

However, when I build a project, the error of undefined reference appears. Please help me.

PS: If main.cpp references to 2 libraries such as l1.h and l2.h. How to link these to main.cpp?

4

1 回答 1

2

您应该提供错误。不过,您似乎缺少链接到某些库的信息。

另请注意,这是一个 CMake 问题,而不是 KDevelop 的问题。如果你研究 cmake,你可能会找到更多的文献。

于 2014-10-09T00:25:28.473 回答