You are not logged in.

1

Tuesday, July 20th 2004, 7:27am

how to builtdand use dynamic library in Linux?

I need to build a dynamic library and use it .

I am using RedHat 9.0

the step I have tried:

write the .h and .cpp files as usual(not special define,just as it performs as a common running file.And if I make it ,it can run smoothly.

then I delete the make file,and rebuid it by
command:

qmake -project "CONFIG += qt dll console warn_on release"

and :

qmake
make

then it general a .o file.A friend tell me it can be just rename to a .so file.So I do ti.

than I use qtLibrary to load it.But it can't get library module.
do someone know how to do it?
thanks!!

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

2

Tuesday, July 20th 2004, 8:33am

Check the CONFIG line in the .pro file.

When qmake generates a Makefile for a dynamic library, the target will be
libTARGET.so

Maybe you either have staticlib in the CONFIG line inside the file or TARGET has to be definied.

Cheers,
_
Qt/KDE Developer
Debian User

3

Tuesday, July 20th 2004, 9:20am

but I can't find .o target in the make file

it is auto general,and I can't find it tell to make a .o or .so file

4

Tuesday, July 20th 2004, 10:31am

also try to gernate the make file as this:

qmake -project "DEFINES += QT_DLL CONFIG +=dll"

still can't work

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

5

Tuesday, July 20th 2004, 10:47am

Don't regenerate the pro file every time, there is no need for that.

Just do it once and then check it or write it manually.

Check that TEMPLATE is lib

Cheers,
_
Qt/KDE Developer
Debian User

6

Tuesday, July 20th 2004, 12:31pm

thanks

I have read the manual,but can't find the information I need:-(

rhg

Trainee

  • "rhg" is male

Posts: 178

Location: Velbert, Germany

Occupation: senior software developer

  • Send private message

7

Tuesday, July 20th 2004, 1:05pm

Look here:
http://doc.trolltech.com/3.3/qmake-manual-5.html

Read about templates. What you need is a line like this in your .pro file:
TEMPLATE = lib

Next, add "dll" to your CONFIG as you already did:
CONFIG += dll

About auto-creating your .pro file. Normally, you do a qmake -project *once*. Afterwards, you edit the generated .pro and add things as you require. So simply do a qmake -project, then edit it: Add TEMPLATE = lib (remove any existing TEMPLATE) and add CONFIG += dll.

8

Tuesday, July 20th 2004, 1:55pm

thanks!!!!

I am reading.

...my poor English:-((

thanks!!!!!

9

Tuesday, July 20th 2004, 3:25pm

still didn't solve

I use

qmake -project -t lib

to create it.than I get a libfortst.so.1.0.0
but I can't use it!!

than I use funpoint=new QLibrary("libfortst");
libfortst->load();

but failed!!!


my god.....

10

Tuesday, July 20th 2004, 3:42pm

and I can't run it!

I just try to copy a .so file from and than rename it to my libray.But it still pass!
so should I change my code for test?

(
newLib=new QLibrary("libname");
newLib->load();

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

11

Tuesday, July 20th 2004, 3:45pm

Library name is without lib.

Some Qt versions have a bug though, where you can retry using libname.so

Anyway, the lib has to be in a path where libs are searched.
For testing you can do

Source code

1
export LD_LIBRARY_PATH=/path/to/project/dir


Cheers,
_
Qt/KDE Developer
Debian User

12

Tuesday, July 20th 2004, 3:53pm

I have put it in the same directory

I think it will search the same path ,doesn't it?
I am very puzzle that why it can't even load a system .so?The code can run in the WIN32 envionment with a dll.

13

Tuesday, July 20th 2004, 3:57pm

or can I do it in another way?

can I get a mod file for QT,and than use the gcc to compile to a .so file?

and do I have a way to check if the .so file is valid?

14

Tuesday, July 20th 2004, 6:00pm

still no idea

I suppose someone have try to do it ,right?
or can you ask some friend for me ?
thanks!!!








......................the 4 night without sleep ...................

Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

15

Tuesday, July 20th 2004, 9:13pm

You can also add additonal searchpaths using QApplication::addLibraryPath

But if it doesn't work with a system library, you maybe give a wrong name to QLibrary.
Did you try both ways?
Once only the name and once libName.so?

Cheers,
_
Qt/KDE Developer
Debian User

16

Tuesday, July 20th 2004, 9:23pm

I think I put the correct name

because the program is very short.


very very very mazy..........

can you give me a set of example?
including make file and link it to run?

thanks for the help you gave me !

e8johan

Professional

  • "e8johan" is male

Posts: 1,195

Location: Sweden

  • Send private message

17

Wednesday, July 21st 2004, 9:57am

RE: I think I put the correct name

The JSeries does just what you want. It builds a library and a set of examples using that library. Check it out and look at the .pro-files. It is available from here: http://www.digitalfanatics.org/e8johan/p…ries/index.html .