在makefile中使用库路径 [英] Using library paths in makefiles

查看:920
本文介绍了在makefile中使用库路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这样的makefile:

I have written a makefile like this:

HEADER = -I./cygdrive/c/cpros/kajj/source4
LIBB = -L./cygdrive/c/cpros/kajj/source1   -L./cygdrive/c/cpros/kajj/source2
LIBRA = -larith -ldekk

target : game.o 
    gcc $(HEADER)   $(LIBB)  $<  -o  $@  $(LIBRA)   

game.o : game.c 
    gcc -c  game.c

我创建了我自己的静态库,并包含头文件路径和库路径。当我执行我的makefile它给出一个错误,说
/ usr / lib / gcc 找不到 -larith -ldekk

I have created my own static library and included the header file path and library path. When I execute my makefile it gives an error saying that /usr/lib/gcc cannot find -larith -ldekk.

它指向lib /目录,但它不在那里: -ldekk -larith 分别在source1和source2文件中。

It is pointing to the lib/ directory but it is not over there: -ldekk and -larith are in source1 and source2 files respectively.

如何解决此错误?

推荐答案

而不是 -L./cygdrive/c ,使用 L / cygdrive / c 。点使得库路径与当前目录相关,即它将寻找当前文件夹而不是驱动器C的 cygdrive 子文件夹。

Instead of -L./cygdrive/c, use -L/cygdrive/c. The dot makes the library path relative from the current directory, i.e. it will look for a cygdrive subfolder of the current folder instead of drive C.

这篇关于在makefile中使用库路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆