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?
You should provide the error. Nevertheless, it looks like you are missing to link against some libraries.
Also note this is a CMake issue, not a KDevelop's. You'll probably find more literature if you research cmake.