This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Trouble with Plasma API

Tags: None
(comma "," separated)
far_away
Registered Member
Posts
5
Karma
0
OS

[SOLVED] Trouble with Plasma API

Sun Jan 18, 2009 7:24 pm
Hello,

I try to write my first plasmoid but I'm stuck with building it. You can see the code here. For some reason it tells me that thread is not a type when I try declare a object of type thread in plasmoid.hpp. I don't understand the way Qt's buildsystem so far, hence I have no idea how I can fix that problem.

Could somebody tell me how I can build this code, please?

P.S.: the imap class in imap.hpp isn't important and can be ignored for testing.

Last edited by far_away on Sun Jan 18, 2009 7:57 pm, edited 1 time in total.
DanielW
KDE Developer
Posts
71
Karma
0
OS

[SOLVED] Trouble with Plasma API

Sun Jan 18, 2009 10:19 pm
OK, it would help if you paste the compile errors here.

But anyway, you get the error there, that it doesn't know thread ?

thread *thrd = new thread ();

It seems you are missing an include thread.hpp or what ever it is called in your plasmoid.cpp.


DanielW, proud to be a member of KDE forums since 2008-Oct.
far_away
Registered Member
Posts
5
Karma
0
OS

[SOLVED] Trouble with Plasma API

Mon Jan 19, 2009 5:22 pm
DanielW wrote:It seems you are missing an include thread.hpp or what ever it is called in your plasmoid.cpp.


Where do I miss it? I don't know what the problem is since I am including "thread.hpp" in "plasmoid.hpp" which is included in "plamoid.cpp". It doesn't make any difference whether I include thread.hpp or thread.moc.
Anyway, here is the compiler output.
Code: Select all
Generating plasmoid.moc                   
Scanning dependencies of target plasma_applet_tutorial1
[ 33%] Building CXX object CMakeFiles/plasma_applet_tutorial1.dir/plasma_applet_tutorial1_automoc.o
[ 66%] Building CXX object CMakeFiles/plasma_applet_tutorial1.dir/plasmoid.o                       
In file included from /home/basti/plasma_mail/plasmoid.cpp:1:                                     
/home/basti/plasma_mail/plasmoid.hpp:28: Fehler: »thread« bezeichnet keinen Typ                   
/home/basti/plasma_mail/plasmoid.cpp: In member function »virtual void PlasmaTutorial1::init()«:   
/home/basti/plasma_mail/plasmoid.cpp:34: Fehler: »thrd« wurde in diesem Gültigkeitsbereich nicht definiert                                                                                               
/home/basti/plasma_mail/plasmoid.cpp:34: Fehler: expected type-specifier before »thread«             
/home/basti/plasma_mail/plasmoid.cpp:34: Fehler: expected `;' before »thread«
/home/basti/plasma_mail/plasmoid.cpp: At global scope:
/home/basti/plasma_mail/plasmoid.cpp:46: Warnung: unbenutzter Parameter »option«
make[2]: *** [CMakeFiles/plasma_applet_tutorial1.dir/plasmoid.o] Fehler 1
make[1]: *** [CMakeFiles/plasma_applet_tutorial1.dir/all] Fehler 2
make: *** [all] Fehler 2


My cmakelist.txt is
Code: Select all
# Project Needs a name ofcourse
project(plasma-tutorial1)

# Find the required Libaries
find_package(KDE4 REQUIRED)
include(KDE4Defaults)

add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(
   ${CMAKE_SOURCE_DIR}
   ${CMAKE_BINARY_DIR}
   ${KDE4_INCLUDES}
   )

# We add our source code here
set(tutorial1_SRCS thread.hpp plasmoid.cpp imap.cpp)

# Now make sure all files get to the right place
kde4_add_plugin(plasma_applet_tutorial1 ${tutorial1_SRCS})
target_link_libraries(plasma_applet_tutorial1
                      ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS})

install(TARGETS plasma_applet_tutorial1
        DESTINATION ${PLUGIN_INSTALL_DIR})

install(FILES plasma-applet-tutorial1.desktop
        DESTINATION ${SERVICES_INSTALL_DIR})


There is another annoying thing I noticed: when I try to use std::exceptions in my plasmoid it tells me that exceptions are disabled and that I should the -fexceptions command. Where do I have to enter it?

Thanks for your help!
DanielW
KDE Developer
Posts
71
Karma
0
OS

[SOLVED] Trouble with Plasma API

Tue Jan 20, 2009 1:20 am
far_away wrote:
DanielW wrote:It seems you are missing an include thread.hpp or what ever it is called in your plasmoid.cpp.


Where do I miss it? I don't know what the problem is since I am including "thread.hpp" in "plasmoid.hpp" which is included in "plamoid.cpp". It doesn't make any difference whether I include thread.hpp or thread.moc.


Well in your linked source (which is quite hard to read) you are including thread.moc. I think it should be thread.hpp.

You have "// **** Plasmoid.hpp" but you inculde "plasmoid.hpp"

Only a error in your paste? Well, I am lost now. It would really help if you could upload your complete source with CMakeList.txt somewhere (or mail it to me ).

far_away wrote:There is another annoying thing I noticed: when I try to use std::exceptions in my plasmoid it tells me that exceptions are disabled and that I should the -fexceptions command. Where do I have to enter it?

Thanks for your help!


Well -fno-exceptions is default in parts of KDE, as far as I know for performance reasons. I do not really know if you can savely use -fexceptions and worse: I do not know how to set it. Somewhere in your CMakeList you should be able to set compiler switches.


DanielW, proud to be a member of KDE forums since 2008-Oct.
pinotree
KDE Developer
Posts
222
Karma
7
OS

[SOLVED] Trouble with Plasma API

Tue Jan 20, 2009 1:31 am
far_away wrote:There is another annoying thing I noticed: when I try to use std::exceptions in my plasmoid it tells me that exceptions are disabled and that I should the -fexceptions command. Where do I have to enter it?


In your CMakeLists.txt, before declaring what needs exceptions, add:
Code: Select all
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")


Pino Toscano
far_away
Registered Member
Posts
5
Karma
0
OS

[SOLVED] Trouble with Plasma API

Tue Jan 20, 2009 5:25 pm
DanielW wrote:It would really help if you could upload your complete source with CMakeList.txt somewhere (or mail it to me ).

Okay, you can download it from here.

Thanks!
DanielW
KDE Developer
Posts
71
Karma
0
OS

[SOLVED] Trouble with Plasma API

Wed Jan 21, 2009 12:51 am
far_away wrote:Okay, you can download it from here.

Thanks!


Ok, got it to compile. (For some reason it doesn't work with the class name thread.. Works with "threadu" not sure why) and link.

There are sme other changes too. So best you diff it with your source to see all changes.

But it crashes plasma. Didn't look further into it (do not know much about the plasma api anyway).

You download the "fixed" version here: http://arch4.der-winti.de/kde/bla.tar.gz


DanielW, proud to be a member of KDE forums since 2008-Oct.
far_away
Registered Member
Posts
5
Karma
0
OS

[SOLVED] Trouble with Plasma API

Wed Jan 21, 2009 4:51 pm
It works now! :-)

Thank you very much.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell