LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-06-2013, 07:58 AM   #1
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204
Blog Entries: 1

Rep: Reputation: 15
Smile My newly compiled programs/applications do not work as i expected


Hello everybody
after a long period in self learning/training now i have created nearly 20 programs using C Programming Language , these programs are successfully compiled by gcc ...but the problem is that:
-those which are as simple as "hello world"/printf just act/respond in terminal ..i can not use them on desktop screen while i need a printf statement to be able to appear wherever i need.
-those applications which are more complicated (having some other words like : do , while ; if; ..to me have unknown activity. in other words they do not merge/show a gui but just are active in background . when i check their activity by a system monitor program it shows that unlike other processes which are usually slept waiting for something to happen , they are very active using up to 50 percent of user cpu (individually) but not interactive with user/me and no gui .
my question is which of the following possibilities is the reason for such behavior:
1-Do they need more time to prepare needed constituents like skin/window/dialog-boxes ...etc?
2-are there any inhibitory factors preventing their full activity?
3-is/are there any defect/defects in my programing ? ...if so how were they successfully compiled/linked by gcc ?
only one of them was windowed with systemd/plasma
I am using Mandriva2012 on my computer
I appreciate any help in advance Regards irajjs
 
Old 09-06-2013, 10:55 AM   #2
NeXuS_2006
Member
 
Registered: Dec 2003
Distribution: Fedora
Posts: 64

Rep: Reputation: 18
Its really impossible to give you specific advice on 20 different programs without seeing even a single line of code

You know simple programs like hello world run from the terminal, and display only there. It takes a lot more code than a print statement to build a window, tell it where to appear and how to behave, and display things inside. Nothing will have a GUI by default, you have to program that. Most people use a toolkit like Qt or GTK+, which has all the pieces you need, look for a simple tutorial on one of those to learn how to create a simple window that displays a string, for example. I'm still learning too, so I don't really know what you did with systemd or plasma, but maybe its time to go back to those tutorials too?

I would suggest you post the code from one of your programs on a place like codereview (its a stack exchange website), so people can give you feedback on your code. This is just a wild guess - I'll bet your programs that are taking up a lot of CPU are doing a lot of work, or at least blocking their thread waiting on some input or something, whereas more advanced programs are properly threaded, etc.

Anyway, good luck, keep at it, yadda yadda. I know how hard it is, I've been teaching myself java/android and dabbling in ruby and C since March, its not always easy to wrap your mind around all the details at first.
 
1 members found this post helpful.
Old 09-08-2013, 03:56 PM   #3
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation Discovered one error....Bad window parameter

Quote:
Originally Posted by NeXuS_2006 View Post
Its really impossible to give you specific advice on 20 different programs without seeing even a single line of code

You know simple programs like hello world run from the terminal, and display only there. It takes a lot more code than a print statement to build a window, tell it where to appear and how to behave, and display things inside. Nothing will have a GUI by default, you have to program that. Most people use a toolkit like Qt or GTK+, which has all the pieces you need, look for a simple tutorial on one of those to learn how to create a simple window that displays a string, for example. I'm still learning too, so I don't really know what you did with systemd or plasma, but maybe its time to go back to those tutorials too?

I would suggest you post the code from one of your programs on a place like codereview (its a stack exchange website), so people can give you feedback on your code. This is just a wild guess - I'll bet your programs that are taking up a lot of CPU are doing a lot of work, or at least blocking their thread waiting on some input or something, whereas more advanced programs are properly threaded, etc.

Anyway, good luck, keep at it, yadda yadda. I know how hard it is, I've been teaching myself java/android and dabbling in ruby and C since March, its not always easy to wrap your mind around all the details at first.
Thank you for your help
Any way i found an error in relation with some of these programs which is : Bad window parameter ...
I did not have enough knowledge in creating suitable windows...what i have done is nearly as such :
#while("............................................\n");
#do("create/make/open/show/merge a window to print the search/scan results on that\n");
#while..............
#do("create/make......a Dialog Box...\n");
#printf(".................\n");
#do("create/make.....a Message Box to be printed on it\n");
.........
.........
so on !
Still i do not know better syntax for the purpose.
I am going to study and try more.
Regards
 
Old 09-10-2013, 05:34 AM   #4
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation new programs grab some windows which are on taskbar!

hi
when i auto-start them to be opened after kde while start-up they are inside a terminal window and mostly grab the other windows/programs (or their skin) around them minimized in the task-bar!
 
Old 09-10-2013, 05:38 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Moderator Response

Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
1 members found this post helpful.
Old 09-10-2013, 05:57 AM   #6
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation my programes seem to be kind of isolated!?

Hi
when i go to add/remove programs in drakconf i do not see them in the list of installed programs !
They are on my bin folder but i have copied them to usr/bin/ ....but i think still they do not have enough support of the other programs because if they had this support they must have been in the list of working processes automatically and they must have been configured/managed ....
are there make/install tests for such self made programs to find out what would be the problems?
Regards
 
Old 09-12-2013, 01:19 PM   #7
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation What is my programming language?!

Hello
As i noticed my self made programs do not seem to be written as normal C programs .....for example : in case of if command or while or do ...in C programming others use expressions/conditions and statements/commands ....but what i have written are all statements! and i do not know exactly why gcc has compiled them(may be because gcc does not see/care about what is inside the braces/strings)...anyway , i am amazed about why there are no errors/notifications/messages if there exist problems!while my programs are very actively working(i do not know what are they doing but i am very curious about that) , off course as i said before i noticed just one error in case of some of them which was about : Bad Window , invalid window parameter , but that error just appeared while i automatically started them with kde autostart program but not at the times when i run them in terminal or click on them or run them by krunner....
Still i am working hard to find the problem/problems and today i have included assert.h to show me if any errors...
What i know is that my computer now is working much better and more stable with better graphical state ...etc
Thank you for spending your time to read this

Last edited by irajjs; 09-12-2013 at 01:24 PM. Reason: one word dictation correction
 
Old 09-12-2013, 02:03 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Programs compiled from source including those you have written yourself are not automatically managed by a package manager nor will they automatically show up in any list or menus.

Even if the program compiles correctly it still may not run correctly. The compiler can not anticipate for run time errors.
A program will run happily if no out of bounds conditions exist although not work as expected.
 
Old 09-12-2013, 08:21 PM   #9
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by irajjs View Post
in case of if command or while or do ...in C programming others use expressions/conditions and statements/commands ....but what i have written are all statements! and i do not know exactly why gcc has compiled them(may be because gcc does not see/care about what is inside the braces/strings)...
if, while etc statements in C get executed whenever the expression evaluates to a non-zero integer. Use of the logical ==, != etc results in either a zero or one but any non-zero integer will be treated as a boolean one. So if (x) { ... } executes whenever x != 0.

Note that if (x = y) { ... } (I presume this is what you mean by a statement) is equivalent to:
x = y;
if (x != 0) { ... }

While this is a handy short cut, it means that it is easy to introduce a bug like if (x = y) when what you wanted was if (x == y) which is an entirely different thing.
 
1 members found this post helpful.
Old 09-13-2013, 07:21 PM   #10
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation How should i know about what is wrong?

Quote:
Originally Posted by michaelk View Post
Programs compiled from source including those you have written yourself are not automatically managed by a package manager nor will they automatically show up in any list or menus.

Even if the program compiles correctly it still may not run correctly. The compiler can not anticipate for run time errors.
A program will run happily if no out of bounds conditions exist although not work as expected.
Hello
And thanks for your attention
What i know about my applications:
-MIME Type application/x-excutable
-They are very active when i see them in system monitor
-they use 44-48 k memory and nearly 120k shared memory
-they overall use up to 95 % user CPU ,so if one of them is started the same amount is used as if 12 of them simultaneously run but when more than one is running cause a lower speed in computer doing other ordinary daily jobs like playing music ....etc off course this CPU usage is different in different states ...usually they are in harmony with other processes .....although they never sleep ...always doing somethings unknown to me
-they do not show any output even if they work for hours too actively
-i have set their permission to 755
-some of my applications are about monitoring,searching.scanning.answering,reporting , some of them should create Dialog Boxes or Message boxes and should message/notify me .....but the outcome is nothing ....just High CPU usage ...and a better state of computer at least i expect notifications about any out-of-bounds-conditions..anyway may be security settings prevents program full activity ...but what about their 755 permission level?
I will not give up i am used to destroying my whole software and remaking/reinstalling them several times....and each time a more advanced state has been and would be the result.
Regards
 
Old 09-13-2013, 07:45 PM   #11
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Smile what i mean

Quote:
Originally Posted by psionl0 View Post
...........
..........

Note that if (x = y) { ... } (I presume this is what you mean by a statement) is equivalent to:
x = y;
if (x != 0) { ... }...............
........
Hi
As i know an expression becomes a statement when you put a semicolon to the end of that like this (.......);
i have read instructions such as yours ....some of them are not what i want to follow/agree! and some of them are not fully understood/justified by me...in my view The ANSI/ISO are just standards set by some people but not the ultimate/best ways/instructions ...i am trying to develop anything! and off course i use all possible/efficient/working means...so i am not just a follower!
Regards

Last edited by irajjs; 09-14-2013 at 01:25 AM. Reason: changed a wrong word
 
Old 09-13-2013, 08:40 PM   #12
NeXuS_2006
Member
 
Registered: Dec 2003
Distribution: Fedora
Posts: 64

Rep: Reputation: 18
I cannot really understand what you are saying, or need help with. Why don't you post some code of the problem apps, or at least part of the code you think is malfunctioning, or tell us anything specific about any of your problems, then we might be able to say something useful to you
 
Old 09-13-2013, 08:41 PM   #13
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by irajjs View Post
Hi
As i know an expression becomes a statement when you put a punctuation mark to the end of that like this (.......);
i have read instructions such as yours ....some of them are not what i want to follow/agree! and some of them are not fully understood/justified by me...in my view The ANSI/ISO are just standards set by some people but not the ultimate/best ways/instructions ...i am trying to develop anything! and off course i use all possible/efficient/working means...so i am not just a follower!
Regards
I don't know what this means.

If you are saying that you shun the programming language's rules of syntax in favour of your own then you should hardly be surprised if the program does not do what you expect.

Last edited by psionl0; 09-13-2013 at 08:43 PM.
 
Old 09-14-2013, 02:05 AM   #14
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You can't debug twenty programs at once. Start over and build, debug, correct them one at a time. Post full code here for each (one at a time and probably one per forum thread) -that's the only way you'll get any meaningful help.
 
Old 09-14-2013, 02:06 AM   #15
irajjs
Member
 
Registered: Jan 2010
Location: Karaj , Iran
Distribution: Mandriva 2012
Posts: 204

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Exclamation I just say that i want to know the state/problem/problems of my applications

Quote:
Originally Posted by NeXuS_2006 View Post
I cannot really understand what you are saying, or need help with.
What i say is that in spite of my applications being compiled successfully and being very active(as shown by their continuous cpu usage) , still:
- there is no clear evidence of what they are/were doing ...no interaction...no message/notification....no error ...no log ! no GUI ...no apparent conflict...., and , how do i find out about all these ?
i wanted to attach the source of one of them to be viewed but upload error prevented because file was considered as : invalid file ......
Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
My newly bought hdd-s seem to have lower than expected rw-speed MasterOfTheWind Linux - Hardware 5 06-24-2008 09:32 AM
Problems with newly compiled kernel, not recognized as such and does not work WorkingClassHero Linux - Newbie 1 02-03-2008 12:19 PM
keyboard won't work with newly compiled kernel dr_zayus69 Linux - Hardware 10 06-05-2005 11:23 AM
Newly compiled kernel behaves as if it was the old one? grayFalcon Linux - Software 4 06-03-2004 04:52 AM
compiled Qt programs no longer work - libqt-mt.so.3 error BluePyre Linux - Software 1 05-30-2004 05:42 PM

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

All times are GMT -5. The time now is 08:56 PM.

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