[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: Sv: [CPROG] cannot open -lX11: No such file or directory



Peter Naldal wrote:

> >Prøv at finde det sted i Makefile hvor der står LDFLAGS eller noget
> >lignende. Der tilføjer du så -L/usr/X11R6/lib, så linien kommer til at
> >se ud lidt som dette (Ikke nødvendigvis præcis)
> >LDFLAGS= -L/usr/X11R6/lib -lX11
>
> Jeg kan ikke få LDFLAGS til at virke, men bruger jeg den samme parameter i compiler kaldet så virker det.

LDFLAGS virker i GNU make sammen med implicitte "rules"
hvis du fjerner den explicitte rule:
cyclic_xlib: cyclic_xlib.c

> gcc -lX11 -o cyclic_xlib cyclic_xlib.c

og i stedet nøjes med kun at specificere dependecies:

cyclic_xlib:    cyclic_xlib.c

bliver dette fortolket via GNU make implcit rule
%:    %.c
til
$CC$ -o cyclic_xlib $CFLAGS$ cyclic_xlib.c $LDFLAGS$

CAVEAT:
Jeg kan ikke lide at bruge implicitte rules da disse *kan* slette headerfiler!!! uden postfix .h der har samme path som en
sourcefile.

Vedhæftet er den den Makefile jeg bruger til mit nuværende projekt:
C++ sockets (det skulle ikke være svært at konveretere til C).
Her er de implicitte rules blevet slået fra og jeg bruger i stedet statiske explicitte rules.
Jeg er ikke helt glad ved strukturering og mangler nogle features som -ci og -co men "make is tool not a target".

I øvrigt er der en ganske fortrinlig sektion om Makefiles i:
info <m> GNU make.

Hej fra Nils!
#Makefile
#nGr_sock C++ socketstream libary version 2.1.1.1
#egcs-2.91.66 port makefile


#tell make where to find source files (GNU make internal variable):
VPATH=../ngr_sockbuf_21_11 ../../sockstream ../../inet ../../local ../../test


#use g++ compiler:
CXX=g++
#compile flags - prepare for debug and warn for anything(seems broken in egcs)
CXXFLAGS=-g -Wall

#include paths:
INCPATH=-I../../ad_hoc -I../ngr_sockbuf_21_11 -I../../sockstream -I../../inet\
	-I../../local

#depend flags:
#do not include standardheaders in dependencies (normal setting):
#DPNDFLAGS=-MM
#include all headers in dependencies - OK this is a standard library project:
DPNDFLAGS=-M

#link flags except libraries and paths:
LDFLAGS=

#link paths and libraries - order is important!:
#include current directory
LIBPATH=-L.
#NOTE: libnGr_sock.a is a softlink to libnGr_sock_21_11.a targeted here
LIBS=-lnGr_sock

#sum of the additional flags
ADD_CXXFLAGS=$(INCPATH)
ADD_DPNDFLAGS=$(INCPATH)
ADD_LDFLAGS=$(LIBPATH) $(LIBS)


#SOURCE FILES SPECIFIKATION:
#source files to be compiled but not linked (ie. discarded) :
#we are relying heavily on templates and would like syntaks checking before
#instanciation:
dummysr=ngr_sockbuf.cc sockstream.cc

#source files to be indexed in library target:
#holds explicit instanciation of templates pertaining to inet/local "namespace"
librasr=inet.cc local.cc

#source files whose objectfile is to be included in every executable target:
sources=

#source files targeted for executable:
implsrc=select_server.cc select_client.cc

#library target (where the librasr goes):
librars=libnGr_sock_21_11.a

#executable target without corresponding source file:
EXECUTA=

#executable targets derived from above:
executs=$(implsrc:.cc=)

#all targets and order of compilation:
targets=$(librars) $(executs) $(EXECUTA)


#derive objectfile and dependfile targets:
all_src=$(dummysr) $(librasr) $(sources) $(implsrc)
dummyob=$(dummysr:.cc=.o)
libraob=$(librasr:.cc=.o)
objects=$(sources:.cc=.o)
implobj=$(implsrc:.cc=.o)
all_obj=$(dummyob) $(libraob) $(objects) $(implobj)
depends=$(all_src:.cc=.d)


#installation variables:
prefix=
includedir=$(prefix)/include
inlinedir=$(includedir)/inline
exec_prefix=$(prefix)
bindir=$(exec_prefix)/bin
libdir=$(exec_prefix)/lib


#sum all flags:
ALL_CXXFLAGS=$(CXXFLAGS) $(ADD_CXXFLAGS)
ALL_DPNDFLAGS=$(DPNDFLAGS) $(ADD_DPNDFLAGS)
ALL_LDFLAGS=$(LDFLAGS) $(ADD_LDFLAGS)

#default rule (seem to have forgot the .PHONY part?)
default:	$(dummyob) $(targets)

#cancel	GNU make non-static implicit rules:
# as these might delete new C++ headers (those without postfix)
# if in the same include path as objectfiles with the same name
% : %.o
% : %.c
% : %.cc


#EXPLICIT STATIC RULES:
$(EXECUTA):	$(EXECUTA):	$(objects)
	$(CXX) $^ $(ALL_LDFALGS) -o $@

$(executs):	%:	$(objects) %.o
	$(CXX) $^ $(ALL_LDFLAGS) -o $@

$(librars):	%.a:	$(libraob)
	ar -rc $@ $^

$(all_obj):	%.o:	%.cc
	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@

#not needed in GNU make
#SHELL=/bin/bash

#build depend files to be included as dependencies
$(depends):	%.d:	%.cc
	$(SHELL) -ec '$(CXX) $(ALL_DPNDFLAGS) $< \
		| sed '\''s/\($*\)\.o[ :]*/\1.o $@:	/g'\'' > $@'

.PHONY:
all:	$(executs) $(librars)

.PHONY:
install:	all
#	cp *.h $(includedir)/.
#	cp inline/*.h $(inlinedir)/.
#	cp $(librars) $(libdir)/.
#	cp $(executs) $(bindir)/.

.PHONY:
clean:
	-rm *.o *.d

.PHONY:
veryclean:	clean
	-rm *~ $(targets)

#include depend files:
include $(depends)




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *