Sunday, July 20th 2008, 2:35am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, April 12th 2008, 5:17pm

Howto compile a project with a custom widget.

Hi,

I created a custom widget in designer and I'm now ready to use the widget in my other projects but I'm getting either compile issues or the program compiles but doesn't run due to the custom widget library.

I first used the custom widget without changing the .pro file and got the following error ;

Source code

1
2
3
4
5
6
7
>make
/usr/bin/qmake -unix -o Makefile currency.pro
g++  -o currency currency.o currxml.o main.o moc_currency.o    -L/usr/lib -lQtXml -L/usr/lib -pthread -pthread -lQtGui -L/usr/X11R6/lib -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
currency.o: In function `Ui_Dialog::setupUi(QDialog*)':
currency.cpp:(.text._ZN9Ui_Dialog7setupUiEP7QDialog[Ui_Dialog::setupUi(QDialog*)]+0x750): undefined reference to `SelectDateWidget::SelectDateWidget(QWidget*)'
collect2: ld returned 1 exit status
make: *** [currency] Error 1


I then changed the .pro file and added :

Source code

1
LIBS += -L/usr/lib/qt4/plugins/designer -lselectdatewidget


Now the compile goes ok but when I run the program I get the following message

Source code

1
2
>./currency
./currency: error while loading shared libraries: libselectdatewidget.so: cannot open shared object file: No such file or directory


What do I need to change to use my new custom widget?

I'm running Qt4.3 on a linux box.

Regards,

Leo Paalvast

This post has been edited 1 times, last edit by "leoclog" (Apr 13th 2008, 8:17pm)

  • Go to the top of the page

Messenger

Intermediate

Posts: 329

Location: Lt

2

Sunday, April 13th 2008, 11:16am

RE: Howto compile a project with a custom widget.

>>./currency: error while loading shared libraries: libselectdatewidget.so: cannot open shared object file: No such file or directory
To run application use
LD_LIBRARY_PATH=/-L/usr/lib/qt4/plugins/designer ./yourprogram
or
LD_LIBRARY_PATH=./ ./yourprogram (and ibselectdatewidget.so in application directory)
Take a look at scripts loading opera, openoffice (soffice), firefox etc.
See /etc/ld.so.conf ldconfig etc.

Maybe it is possible to create static selectdtewidget library. Then application with selectdtewidget will not need external library (so). See qmake CONFIG variable staticlib option.
Fighting fire with fire.
  • Go to the top of the page

3

Sunday, April 13th 2008, 8:16pm

RE: Howto compile a project with a custom widget.

Thanks again messenger, I used the CONFIG += staticlib option and it works fine now,
  • Go to the top of the page

Rate this thread