【发布时间】:2010-03-29 15:33:04
【问题描述】:
我有问题。我写了示例代码,我想构建它没有错误:
main.cpp(.text+0x5): undefined reference to `test()'
图书馆
test1.c
#include <stdlib.h>
void test()
{
puts("Działa");
}
test1.h
#ifndef TEST1_H
#define TEST1_H
extern void test();
#endif
制作文件
all:
gcc -c ./src/test1.c -o ./lib/test1.o
ar rcs ./lib/libtest1.a ./lib/test1.o
程序
main.cpp
#include <test1.h>
int main()
{
test();
return 0;
}
制作文件
all:
g++ -static -I../test1/include -L../test1/lib ./src/main.cpp -o ./build/MyApp -ltest1
我做错了什么?
【问题讨论】: