-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?

Kopro
  • 1
  • 2
  • without posting the actual error there is nothing we can help you with. also: you probably don't want to add io.h (a header file!) to the list of sources. – milianw Oct 09 '14 at 12:20

1 Answers1

2

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.

Aleix
  • 31
  • 1