Makefile problem

Hi,

I have created a .so file and I want to load this lib for compiling another executable file. There is no error reported during makefile process, but when I run the exe file it complains that my library file couldn’t be found. Following is the makefile I use to generate the exe file. Could anyone help me find out the problem? Thank you!

#you can find this header file under $ROOTSYS/test. Please let me know if you need more information
include Makefile.arch

#------------------------------------------------------------------------------

executeO = execute.$(ObjSuf)
executeS = execute.$(SrcSuf)
execute = execute$(ExeSuf)

OBJS += $(executeO)
PROGRAMS += $(execute)

GLIBS += -L${MyDir} -lMylib.so

#------------------------------------------------------------------------------

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
.PHONY:

all: $(PROGRAMS)

$(execute): $(executeO)
$(LD) $(LDFLAGS) $^ $(GLIBS) $(OutPutOpt)$@
$(MT_EXE)
@echo “$@ done”

clean:
@rm -f $(OBJS)

distclean: clean
-@mv -f linearIO.root linearIO.roott
@rm -f $(PROGRAMS) Dict. *.def *.exp
*.root *.ps *.so *.lib *.dll *.d *.log .def so_locations
@rm -rf cxx_repository

.SUFFIXES: .$(SrcSuf)

execute.$(ObjSuf): execute.cxx

.$(SrcSuf).$(ObjSuf):
$(CXX) $(CXXFLAGS) -c $<

[quote]but when I run the exe file it complains that my library file couldn’t be found.[/quote]Is the directory in which you library are located contained in the LD_LIBRARY_PATH?

Cheers,
Philippe.

Hi Philippe,

No, it’s not the LD_LIBRARY_PATH directory. But in the makefile I have provided the full path ${MyDir}

Hongtao

[quote=“pcanal”][quote]but when I run the exe file it complains that my library file couldn’t be found.[/quote]Is the directory in which you library are located contained in the LD_LIBRARY_PATH?

Cheers,
Philippe.[/quote]

Hi,

Humm … this only tells ld where to find the library during the creation of the library (i.e. instead of using a -L). It does NOT tell the executable where to find the library at run-time. You still need to add the directory to the LD_LIBRARY_PATH and/or use the rpath option.

Cheers,
Philippe.

Hi Philippe,

Thanks, I have added the directory to the LD_LIBRARY_PATH and it works well. :smiley:

Best Regards,

Hongtao

[quote=“pcanal”]Hi,

Humm … this only tells ld where to find the library during the creation of the library (i.e. instead of using a -L). It does NOT tell the executable where to find the library at run-time. You still need to add the directory to the LD_LIBRARY_PATH and/or use the rpath option.

Cheers,
Philippe.[/quote]