LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2003, 08:07 PM   #1
mrogerf
LQ Newbie
 
Registered: Jul 2003
Location: Brazil
Distribution: Archlinux
Posts: 20

Rep: Reputation: 0
Question Problem linking KDevelop projects


First of all, sorry for my English mistakes.

I'm trying to learn how to develop KDE C++ Aplications and I choose to use KDevelop (3.0 alpha 4 gideon) to help me.
I was using Larrosa's Tutorials ( devel-home.kde.org/~larrosa/tutorial/) and I was re-writing its codes in Kdevelop.

Well, the problem is that I always have the follow error when I try to build the project ( it compiles fine, the problem is the linking operation). In this case is the tutorial P4:
": undefined reference to `KHTMLPart::KHTMLPart[in-charge](QWidget*, char const*, QObject*, char const*, KHTMLPart::GUIProfile)'"

I have a similar error when I try to build my rewrited code from P3 tutorial, however it was about KFileDialog and not KHTMLPart.

I'm sure that I don't forgot any command line ( I checked it hundred of times, besides it compiles OK). The code from that I copied is ok too, because I can build it's source without any error.

I really think that's a problem about Makefile (maybe autoconf), because I create a Kdevelop project (using the option: "a simple KDE project") with the same name as the tutorial (p4). Then, I copy the sources (main.cpp, p4.h and p4.cpp). I try to build it, but I got the same error as above. However when I copy the file "Makefile.am" from the tutorial's sources to my project, it works! I try to see if there are many differences between these files, but there are many and these files and uncompreensive for me.

I also reisntall libs, devel packages, update them (to slackware current version), use kdevelop 2.15, but nothing.

So, to finish, anyone knows how can I solve this problem or, at least, anyone has follow these tutorials like me (rewriting code into Kdevelop) and had success ? What distro, gcc or kdevelop version did you use ?

I will be very pleased for any help.
 
Old 08-03-2003, 02:25 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
As a workaround, you can add -lkhtml to Project options-> LDFLAGS. It's not a perfect solution, but should work.
 
Old 08-03-2003, 05:23 PM   #3
mrogerf
LQ Newbie
 
Registered: Jul 2003
Location: Brazil
Distribution: Archlinux
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks a lot for your attention, Mara. Unfortunately, It didn't work yet. I got the follow error in configure :

* configure: error: C compiler cannot create executables
* See `config.log' for more details.
* *** Exited with status: 77 ***

checking the config.log I noticed the follow:

configure:2530: gcc -lkhtml conftest.c >&5
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../../i486-slackware-linux/bin/ld: cannot find -lkhtml
collect2: ld returned 1 exit status
configure:2533: $? = 1

I also tried to use:
- khtmlw ( its a option that I see in
http://www.kde.gr.jp/help/doc/kdevel...r-options.html )

but this time I got the error (Make output) :
* g++: unrecognized option `-khtmlw'
-------------------------------------------------------------------------------

I'm really confused. I was looking for a solution for this in the last three weeks. What I just want is to build a simple (VERY simple) web browser using KParts, and I found some tutorials (in the net, magazines) and all of them use the this solution:

KURL url = "http://www.kde.org";
KHTMLPart *w = new KHTMLPart();
w->openURL(url);
w->view()->resize(500, 400);
w->show();
-----------------------------------------------------------
I tried this solution many, many times (also copying the complete source froma a larrosa's tutorial - there is a link in the first post) but always with the same error:
: undefined reference to `KHTMLPart::KHTMLPart[in ... bla bla bla..

Checking more, I found that the code generated to Kdevelop 3 (gideon), when I create a project "Application Framework", use ReadOnlyPart and it is able to open URLs ( but I doesn't have success to extending it with BrowserExtension yet - the extension doesn't send the signal OpenURLRequest :- ( ).

So, just one more question:
Is KHTMLPart a obsolete object ?
 
Old 08-04-2003, 03:00 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Here's an output of my compilation of the tutorial (downloaded the full archive, etc):
Code:
make[1]: Entering directory `/repository/sources/kdetutorial-1.2/p4'
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/kde/include 
-I/usr/lib/qt-3.1.2/include -I/usr/X11R6/include   
-DQT_THREAD_SUPPORT  -D_REENTRANT  -O2 
-fno-exceptions -fno-check-new  -c p4.cpp

g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/kde/include -I/usr/lib/qt-3.1.2/include -I/usr/X11R6/include   
-DQT_THREAD_SUPPORT  -D_REENTRANT  -O2 
-fno-exceptions -fno-check-new  -c main.cpp

/usr/lib/qt-3.1.2/bin/moc ./p4.h -o p4.moc.cpp

g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/kde/include -I/usr/lib/qt-3.1.2/include -I/usr/X11R6/include   
-DQT_THREAD_SUPPORT  -D_REENTRANT  -O2 
-fno-exceptions -fno-check-new  -c p4.moc.cpp

creating p4_meta_unload.cpp

g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/kde/include -I/usr/lib/qt-3.1.2/include-I/usr/X11R6/include   
-DQT_THREAD_SUPPORT  -D_REENTRANT  -O2 
-fno-exceptions -fno-check-new  -c p4_meta_unload.cpp

/bin/sh ../libtool --mode=link --tag=CXX g++  -O2 -fno-exceptions
 -fno-check-new  -L/usr/X11R6/lib -L/usr/lib/qt-3.1.2/lib 
-L/opt/kde/lib  -R /opt/kde/lib -R /usr/lib/qt-3.1.2/lib -R 
/usr/X11R6/lib -o p4  p4.o main.o p4.moc.o p4_meta_unload.o  
-lkhtml -lkdeui -lkdecore -lkio -lqt-mt  -lpng -lz -lm -lXext -lX11 
-lresolv -lSM -lICE -lpthread 

mkdir .libs

g++ -O2 -fno-exceptions -fno-check-new -o p4 p4.o main.o 
p4.moc.o p4_meta_unload.o  -L/usr/X11R6/lib 
-L/usr/lib/qt-3.1.2/lib -L/opt/kde/lib /opt/kde/lib/libkhtml.so 
-L/usr/lib/qt/lib -L/usr/lib/gcc-lib/i386-slackware-linux/3.2.2 
-L/usr/lib/gcc-lib/i386-slackware-linux/3.2.2/../../../../i386-slackware-linux/lib
 -L/usr/lib/gcc-lib/i386-slackware-linux/3.2.2/../../.. 
-L/usr/i386-slackware-linux/bin -L/usr/i386-slackware-linux/lib 
-ljpeg -L/usr/lib /opt/kde/lib/libkdeprint.so /opt/kde/lib/libkparts.so 
/opt/kde/lib/libkutils.so /opt/kde/lib/libkio.so /opt/kde/lib/libkdeui.so
 /opt/kde/lib/libkdesu.so /opt/kde/lib/libkdecore.so 
/opt/kde/lib/libDCOP.so -ldl -lXinerama /usr/lib/libart_lgpl_2.so 
/opt/kde/lib/libkdefx.so -lXrender -lutil /usr/lib/./libstdc++.so -lc 
-lgcc_s -lqt-mt -lpng -lz -lm -lXext -lX11 -lresolv -lSM -lICE 
-lpthread -Wl,--rpath -Wl,/opt/kde/lib -Wl,--rpath -Wl,/usr/lib/. 
-Wl,--rpath -Wl,/opt/kde/lib -Wl,--rpath -Wl,/usr/lib/. -Wl,--rpath 
-Wl,/usr/lib/qt-3.1.2/lib -Wl,--rpath -Wl,/usr/X11R6/lib -Wl,--rpath 
-Wl,/usr/lib/qt/lib

make[1]: Leaving directory `/repository/sources/kdetutorial-1.2/p4'
Youu can see that the linking command (the last one) is quite long. So what you need to add is probably something like {B] -L/opt/kde/lib /opt/kde/lib/libkhtml.so[/B] (if it's not enough, copy more).

Last edited by Mara; 08-04-2003 at 03:04 PM.
 
Old 08-04-2003, 06:53 PM   #5
mrogerf
LQ Newbie
 
Registered: Jul 2003
Location: Brazil
Distribution: Archlinux
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks again, Mara. I also successful compiled the tutorial like you. The problem is when I try to create my own project using Kdevelop ( I tried gideon an 2.15).

If you want a example I did exactly the follow:

- create I "Simple KDE Application" using kdevelop . (I used the name "Z" to my project)

- make and run it . OK. A dialog showing "Hello World" appeared. Until now it's fine

- Now, in the file z.h , I put the line:
#include <khtml_part.>

-and inside class definition:
public: KHTMLPart *browser;

- I buid it again and run. No problem.

- Now in the z.cpp I replace the lines:

#include <qlabel.h>
new QLabel( "Hello World", this, "hello label" );

for

#include <qvbox.h>
QVBox *vbox = new QVBox (this);

- I also put the line:
setCentralWidget (vbox);

- build the project again (to be sure that It's still running. OK, but now I got a empty dialog (of course, vbox isn't showing anything)

Now the real test:

- below the line "QVBox * vbox = new QVBox (this); " put :

browser = new KHTMLPart (vbox);

- Build it. Ops !!!

: undefined reference to `KHTMLPart::KHTMLPart[in-charge](QWidget*, char const*, QObject*, char const*, KHTMLPart::GUIProfile)'


This is my z.h
-----------------------------------------------------------------------------------------
*
* Copyright (C) 2003 Marcio Roger Ferrari,,, <mrogerf@darkstar>
*/

#ifndef _Z_H_
#define _Z_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kmainwindow.h>
#include <khtml_part.h>

/**
* @short Application Main Window
* @author Marcio Roger Ferrari,,, <mrogerf@darkstar>
* @version 0.1
*/
class z : public KMainWindow
{
Q_OBJECT
public:
/**
* Default Constructor
*/
z();

/**
* Default Destructor
*/
virtual ~z();

public: KHTMLPart *browser;
};

#endif // _Z_H_
---------------------------------------------------------------------------

this is my z.cpp
---------------------------------------------------------------------------
/*
* Copyright (C) 2003 Marcio Roger Ferrari,,, <mrogerf@darkstar>
*/

#include "z.h"

#include <qvbox.h>

#include <kmainwindow.h>
#include <klocale.h>

z::z()
: KMainWindow( 0, "z" )
{
// set the shell's ui resource file
setXMLFile("zui.rc");

QVBox *vbox = new QVBox (this);
browser = new KHTMLPart (vbox);

setCentralWidget(vbox);

}

z::~z()
{
}

#include "z.moc"

----------------------------------------------------------------------------

This problem doesn't make any sense for me :-( .
 
Old 07-18-2004, 01:06 PM   #6
Drynish
LQ Newbie
 
Registered: Mar 2002
Location: Repentigny, QC
Distribution: Slackware 8.0
Posts: 10

Rep: Reputation: 0
Hello...

I have been able to build it:

Just add in Project/ Project Options

In the menu Configure Options:

Linker Flags: -L /where/is/kde/lib/libkhtml.so

Michel
 
Old 07-18-2004, 02:01 PM   #7
mrogerf
LQ Newbie
 
Registered: Jul 2003
Location: Brazil
Distribution: Archlinux
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks Drynish for your help. I did not try your solution yet, but I will do it soon.
 
Old 08-08-2005, 09:32 AM   #8
freddy91
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
Thank youy, it works

Hi

I didn't ask for anything but I was very interested by this answer and I confirm that it is the right one.
I had exactly the same problem.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking static and shared libraries in the KDevelop Environment tristanm Programming 15 11-27-2006 09:59 PM
linking error using kdevelop 3.1 gunslinger77 Programming 2 11-24-2004 02:13 PM
glade2 - problem with adding images to projects szparag Linux - Software 0 10-25-2004 04:11 AM
Linking on kdevelop ashwinipahuja Programming 3 06-30-2004 09:15 AM
Linking ACE with KDevelop Kavinjka Programming 5 04-28-2004 05:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration