[SOLVED] My newly compiled programs/applications do not work as i expected
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
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!
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
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
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.
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.
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
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
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
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.
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.
I just say that i want to know the state/problem/problems of my applications
Quote:
Originally Posted by NeXuS_2006
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.