上次发帖就是想问这个问题,由于我一时疏忽,对于sin(12.12)撒出现负值?转不过弯来(是弧度不是度)
各路神仙竞相指招,
对于sin函数为啥有负值,给我上了生动的一课!
结果就没有一个人说我应该在写Makefile时如何加载连接库
我再次提出这个问题,希望指教,用sin函数试试,因为在编译时要连接库
-lm
结果把-lm放哪都不合适,
/***********************test.h
#ifndef _TEST_H__
#define _TEST_H__
void function();
#endif
*****************************************
test.c
#include<stdio.h>
#include"test.h"
void function()
{
double i=sin(12.12);
printf("%f\n",i);
}
***********************************************
#include<stdio.h>
int main()
{
function();
return 0;
}
**********************************
Makefile
main:main.o test.o
gcc -o $@$^
main.o:main.c test.h
gcc -c $<
test.o:test.c test.h
gcc -lm -c $<
clean:
rm *.o
********************
用-lm或者库的绝对路径放哪都不行
望指教
Makefile时连接库文件的问题
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08
- lyre
- 帖子: 77
- 注册时间: 2005-06-28 18:08
/***********************test.h
#ifndef _TEST_H__
#define _TEST_H__
void function();
#endif
*****************************************
test.c
#include<stdio.h>
#include<math.h>
#include"test.h"
void function()
{
double i=sin(12.12);
printf("%f\n",i);
}
***********************************************
#include<stdio.h>
int main()
{
function();
return 0;
}
**********************************
Makefile
main:main.o test.o -lm
gcc -o $@$^
main.o:main.c test.h
gcc -c $<
test.o:test.c test.h
gcc -c $<
clean:
rm *.o
********************
#ifndef _TEST_H__
#define _TEST_H__
void function();
#endif
*****************************************
test.c
#include<stdio.h>
#include<math.h>
#include"test.h"
void function()
{
double i=sin(12.12);
printf("%f\n",i);
}
***********************************************
#include<stdio.h>
int main()
{
function();
return 0;
}
**********************************
Makefile
main:main.o test.o -lm
gcc -o $@$^
main.o:main.c test.h
gcc -c $<
test.o:test.c test.h
gcc -c $<
clean:
rm *.o
********************
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08