PDA

View Full Version : Need help with library linking!



MR.UNOWEN
October 28th, 2009, 06:11 PM
Hello,

Can someone help me get qwt recognized on my system. I've been pulling my hair out trying to figure out what's going on. It will compile but it won't statically link to the qwt library.

When I run it I get, "error while loading shared libraries: libqwt.so.5: cannot open shared object file: No such file or directory"

The path to it is /usr/local/qwt-5.2.0/ of which has the library in .../lib and the headers in .../include

export LD_LIBRARY_PATH=/usr/local/qwt-5.2.0/lib:$LD_LIBRARY_PATH
didn't work

Can someone help me with this problem?

It's driving me nuts ](*,)


Here's my make file:



################################################## ###########################
# Makefile for building: gtst
# Generated by qmake (1.07a) (Qt 3.3.8b) on: Tue Oct 27 21:59:26 2009
# Project: gtst.pro
# Template: app
# Command: $(QMAKE) -o Makefile gtst.pro
################################################## ###########################

####### Compiler, tools and options

CC = gcc
CXX = g++
LEX = flex
YACC = yacc
CFLAGS = -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -lqwt
CXXFLAGS = -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT
LEXFLAGS =
YACCFLAGS= -d
INCPATH = -I/usr/share/qt3/mkspecs/default -I. -I-I -I/usr/local/qwt-5.2.0/include -I-I -I. -I/usr/include/qt3 /usr/local/qwt-5.2.0/include/
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -L/usr/local/qwt-5.2.0/lib/ -lqwt -lqt-mt -lXext -lX11 -lm -lpthread /usr/local/sbin/libqwt.so
AR = ar cqs
RANLIB =
MOC = /usr/share/qt3/bin/moc
UIC = /usr/share/qt3/bin/uic
QMAKE = qmake
TAR = tar -cf
GZIP = gzip -9f
COPY = cp -f
COPY_FILE= $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE= $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
DEL_FILE = rm -f
SYMLINK = ln -sf
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p

####### Output directory

OBJECTS_DIR = ./

####### Files

HEADERS =
SOURCES = gtst.cc
OBJECTS = gtst.o
FORMS =
UICDECLS =
UICIMPLS =
SRCMOC =
OBJMOC =
DIST = gtst.pro
QMAKE_TARGET = gtst
DESTDIR =
TARGET = gtst

first: all
####### Implicit rules

.SUFFIXES: .c .o .cpp .cc .cxx .C

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules

all: Makefile $(TARGET)

$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)

mocables: $(SRCMOC)
uicables: $(UICDECLS) $(UICIMPLS)

$(MOC):
( cd $(QTDIR)/src/moc && $(MAKE) )

Makefile: gtst.pro /usr/share/qt3/mkspecs/default/qmake.conf /usr/share/qt3/lib/libqt-mt.prl
$(QMAKE) -o Makefile gtst.pro
qmake:
@$(QMAKE) -o Makefile gtst.pro

dist:
@mkdir -p .tmp/gtst && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/gtst/ && ( cd `dirname .tmp/gtst` && $(TAR) gtst.tar gtst && $(GZIP) gtst.tar ) && $(MOVE) `dirname .tmp/gtst`/gtst.tar.gz . && $(DEL_FILE) -r .tmp/gtst

mocclean:

uiclean:

yaccclean:
lexclean:
clean:
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
-$(DEL_FILE) $(TARGET) $(TARGET)


FORCE:

####### Compile

gtst.o: gtst.cc

####### Install

install:

uninstall:

dwhitney67
October 28th, 2009, 06:29 PM
Fix these two lines as shown below:


INCPATH = -I/usr/share/qt3/mkspecs/default -I. -I/usr/local/qwt-5.2.0/include -I/usr/include/qt3
...
LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -L/usr/local/qwt-5.2.0/lib/ -lqwt -lqt-mt -lXext -lX11 -lm -lpthread

If indeed you want to statically link the library into your application, then for LIBS use the following:


LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -L/usr/local/qwt-5.2.0/lib/ -static -lqwt -lqt-mt -lXext -lX11 -lm -lpthread

If static linking the library, then the LD_LIBRARY_PATH is not required (at least I don't think so!).

MR.UNOWEN
October 28th, 2009, 06:40 PM
Well I tried the one with static link and I get "collect2: ld returned 1 exit status."

Any idea what's going on? Is it still unable to find things?

dwhitney67
October 28th, 2009, 07:17 PM
I may have been wrong with respect to statically linking a shared-object library. I think you can only statically link in a static library (ie. one with a .a extension).

If you do not have a .a version of the library, then try without the -static in your Makefile, and then rebuild. You will need to use LD_LIBRARY_PATH when you attempt to run the application.

MR.UNOWEN
October 28th, 2009, 08:28 PM
hmm....


By the way, why does this not work:
export LD_LIBRARY_PATH=/usr/local/qwt-5.2.0/lib:$LD_LIBRARY_PATH

Arndt
October 28th, 2009, 09:26 PM
hmm....


By the way, why does this not work:
export LD_LIBRARY_PATH=/usr/local/qwt-5.2.0/lib:$LD_LIBRARY_PATH

You can use the 'ldd' program to see what shared libraries a program needs, and whether it will find them.

dwhitney67
October 29th, 2009, 11:28 AM
hmm....


By the way, why does this not work:
export LD_LIBRARY_PATH=/usr/local/qwt-5.2.0/lib:$LD_LIBRARY_PATH

Because perhaps LD_LIBRARY_PATH has yet to be defined. Verify if it has:


env | grep LD_LIBRARY_PATH

If you find that it is not defined, then the following will suffice:


export LD_LIBRARY_PATH=/usr/local/qwt-5.2.0