简体   繁体   中英

makefile error: /usr/bin/ld: cannot find -llibname and makedepend

I am trying to write my own makefile for small project, my project consists of src directory that contains main.c, file1.c, file2.c, header1.h, and finally header2.h these files use some library from non standard libraries directory that I have created and non standard header file, the libraries directory is located in usr/lib/pr__lib and the header directory is located in usr/include/lib so I should create two makefile.am one will be located in src directory and the other one will be in root directory of the project the makefile.am of the src directory is as shown below:

program_NAME := myproject

AM_CPPFLAGS = \
   -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
   -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
   -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"


bin_PROGRAMS = myproject_AutoProject

program_INCLUDE_DIRS := /usr/bin/srr__bin

program_LIBRARY_DIRS := /usr/lib/srr__lib

AM_CFLAGS = 

AM_CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))

program_lib2 := \
      libsrr\
      libprdsl \
      libtwo \
      libhistogram \
      libhistogram_pic \
      libprlistofarrays \
      libprlistofarrays_pic \
      libprmalloc \
      libvreo 
AM_LDFLAGS = 

AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))

AM_LDFLAGS += $(foreach library,$(program_lib2),-l$(library))

PRDSL_AutoProject_SOURCES = \
   main.c \
   file1.c \
   file2.c

depend :
    makedepend -$(CFLAGS) -$(PRDSL_AutoProject_SOURCES)

all: $(program_NAME)

the second makefile.am is as shown below:

SUBDIRS = src

myproject_AutoProjectdocdir = ${prefix}/doc/PRDSL_AutoProject
myproject_AutoProjectdoc_DATA = \
  README\
  COPYING\
  AUTHORS\
  ChangeLog\
  INSTALL\
  NEWS


INTLTOOL_FILES = intltool-extract.in \
  intltool-merge.in \
  intltool-update.in

EXTRA_DIST = $(myproject_AutoProjectdoc_DATA) \
   $(INTLTOOL_FILES)

DISTCLEANFILES = intltool-extract \
   intltool-merge \
 intltool-update \
 po/.intltool-merge-cache


# Remove doc directory on uninstall
uninstall-local:
  -rm -r $(PRDSL_AutoProjectdocdir)

but i have received the below error:

 /usr/bin/ld: cannot find -llibsrr
 /usr/bin/ld:.......

and the same for the rest of the libraries! I guess that the problem in the depend command here, can anyone tell me how to use the depend command in order to create the dependency automatically and avoid human errors

can you make this change and let me know:

PathToMySource=`pwd` 
Program_INCLUDE_DIRS := /usr/bin/srr__bin

program_LIBRARY_DIRS := /usr/lib/srr__lib

AM_CFLAGS = 

AM_CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))

program_lib2 := \
      $(PathToMySource)/libsrr\
      $(PathToMySource)/libprdsl \
      $(PathToMySource)/libtwo \
      $(PathToMySource)/libhistogram \
      $(PathToMySource)/libhistogram_pic \
      $(PathToMySource)/libprlistofarrays \
      $(PathToMySource)/libprlistofarrays_pic \
      $(PathToMySource)/libprmalloc \
      $(PathToMySource)/libvreo 
AM_LDFLAGS = 

AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))

AM_LDFLAGS += $(foreach library,$(program_lib2),-l$(library))

PRDSL_AutoProject_SOURCES = \
   main.c \
   file1.c \
   file2.c

depend :
    makedepend -$(CFLAGS) -$(PRDSL_AutoProject_SOURCES)

all: $(program_NAME)

I am assuming that the folders are in the directory from where the make file is expected to run.

If they are not please add another variable and set the path. then use that variable in the place of PathToMySource.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM