This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

使用CCS5.2生成静态库的问题



不知道在这里问是否合适,还请各位大牛不吝赐教。

我使用CCS5.2建立了一个生成静态库的工程,包含两个文件,一个是

testlib.h,内容如下:

#ifndef TESTLIB_H_
#define TESTLIB_H_

int testlibp(int);


#endif /* TESTLIB_H_ */

一个是testlib.c内容如下:

#include <stdio.h>
#include "testlib.h"
int testlibp(int x){
printf("lib test results:%d\n",x);
return 0;
}

编译工程生成了一个lib文件,输出的信息为:

==> new archive 'libtest.lib'
==> building archive 'libtest.lib'
==> symbol defined: '_testlibp'
'Finished building target: libtest.lib'

然后我建立了一个新的,生成.out的工程,想在这个工程里调用刚生成的库里testlibp这个函数,就把上个工程生成的lib放到新工程目录下,此外新工程还有两个文件:

testlib.h内容跟上个工程一样。

main.c内容:

#include <stdio.h>
#include "testlib.h"

int main(void) {
int x=5;
testlibp(x);
return 0;
}

编译工程出现错误:

<Linking>

undefined first referenced
symbol in file

--------- ----------------
>> Compilation failure
testlibp(int) ./main.obj

error #10234-D: unresolved symbols remain

这个问题该如何解决?我哪里的设置出现了问题么?