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.
I am a newbie about linux programming.
I have only little idea about Registry and thread.
I have some questions about Registry and thread.
I have a program which is written by VC++6.0
It include some registry and threads.
I am using the RedHat9.2 and Kdevelop/Qt is my programming development tool.
My questions are as follows:
are they similar to Linux?
How can I write a program with registry and thread?
how can I get more information about registry and thread for my reference?
are there any reference books that includes all of the information?
Can anyone help me?
I would be grateful if you can answer my questions
Thanks
1- Thread
Linux (and any posix system) uses pthread. The concept is really similar to win32 threads, but the API and parameters are differents. If you port your application to pthread, you can actually use pthread in windows with the pthread-win32-librairy. (http://sources.redhat.com/pthreads-win32/). You can also check pthread man page.
2- Registry
There is no such thing in linux. You would need to write an interface that opens a config file and reads values. I would do it in the form "key "value" #comment". Dependaing how the original application is written, it can be easy or really hard. For exemple, if all registry call are in a single class, just replace that class, if they are scatered all over, then "find in files" will become your best friend!!! For reference on the win32 registry, see the microsoft web site (developper section -- msdn).
As for the porting issue, I hope you know what you are getting in. There will be all sort of problems and you will need to really undestand the application and the code. I dont want to discourage you. Just want to make sure you realize porting is not an easy task, espeacily if the application was not written with porting in mind!
Usally configs are found in /etc. You could also put your config files in the same folders as your application. Your choise.
As for reading those config, you could write some code to parse the file and read. If the config are really simple, it could be the way to go. For more complex things, you can use the libraiy of awk (or gawk under Linux).
You could also check out gnu flex. I have never used that one. But it can parse text and find expression. It might be a little too powerfull (and complex) for your needs.
As for the format of the file, I would use something that is similar to the registry. A key, value pair.
gnome provides an api similar to the windows registry; I imagine KDE provides one too. I've looked into the gnome one a little -- it's fairly straight forward and yes, your app will still work in a non-gnome desktop, even KDE, as long as the proper gnome shared libraries are installed. That'd be true for the KDE api if there is one, as well.
Search for Blanchette book on Qt3 (available online iirc). There you will find info about threads (QThread class).
As for registry, use QSettings or KConfig classes. They are quite similar and will give you an access to the ini-like configuration db.
Thank you adymo.
I saw the book "Blanchette book on Qt3 " of the "Using Qt's Classes in Non-GUI Threads" but it is just a few pages about the Non-GUI threads .
In fact, my program ( the window version) has GUI threads and non-GUI threads. Also, it has a file that is mainly handle the non-GUI threads.
Can I use the Qt to handle the GUI thread and non-GUI thread OR I use the pthread for non-GUI thread and Qt for GUI thread? which one is better?
In fact, I have a file that mainly handle the thread. However, I don't know how to convert the following codes into Linux.
For me, I don't want to change the structure of this file because if I change it, I need to change all the other files correspondingly. Do anyone know how to migrate them into Linux? or can anyone give me some suggestions / advices that how I can do?
Thank you very much
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.