Announcement

Collapse
No announcement yet.

want to learn how to program in c/c++ in linux

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    want to learn how to program in c/c++ in linux

    Hey all:

    Linux has me very exited about learning how to actually program in c/c++ for linux. I have taken a c++ programming class and want to apply it to programming apps for linux (or doing hardware drivers). ANy ideas or suggestions??

    Also - how do I get started with c programming??

    ironmantis7x

    #2
    Re: want to learn how to program in c/c++ in linux

    well to start with you could install the kdevelop packages to get your ide for kde set up.
    Mark Your Solved Issues [SOLVED]
    (top of thread: thread tools)

    Comment


      #3
      Re: want to learn how to program in c/c++ in linux

      Being also a programming student, here is some free C learning sites:
      http://www.eskimo.com/~scs/cclass/cclass.html
      http://home.netcom.com/~tjensen/ptr/pointers.htm
      http://www.engin.umd.umich.edu/CIS/c...400/index.html
      http://www.bloodshed.net/
      Otto

      Comment


        #4
        Re: want to learn how to program in c/c++ in linux

        also there are a lot examples in linux using the command "make" and the "makefile", a very nice tool for programming projects, because with this you won't need to compile every code.c you have, just those you have modified lately.

        Comment


          #5
          Re: want to learn how to program in c/c++ in linux

          for doing apps, I would check out Qt Creator. I have been using it for the last couple of weeks and it has been the closest to my visual studio experience. Except Qt is a much better API than anything I have used from MS.
          FKA: tanderson

          Comment


            #6
            Re: want to learn how to program in c/c++ in linux

            Up to now, I'v always used kate to write my scripts.

            where I can download Qt creator? i don't find it in the repos.
            Thanx!

            Comment


              #7
              Re: want to learn how to program in c/c++ in linux

              http://www.qtsoftware.com/products/d...97b1e065a976b8
              FKA: tanderson

              Comment


                #8
                Re: want to learn how to program in c/c++ in linux

                cool! thank you

                Comment


                  #9
                  Re: want to learn how to program in c/c++ in linux

                  Allow me to recommend that you use the Qt API and a GUI RAD made specifically for it, Qt-Creator, all of which are in the repository and work well under Jaunty. Before I retired I spent the last three years of my 40 year programming career writing in-house apps using MS Visual Studio C++ 6.0 and the Qt API. Qt-Creator, IMO, is equal to, and in many respects, better than MSVC. When you install Qt4 from the repository install about everything that has Qt4 in its name. Oh, be sure to install gcc++ 4.3.2 (even though 4.3.3 is preinstalled.) The latest release of Qt4 in the repository is 4.5.x

                  For a database try PostgreSQL 8.x. Be sure to install the Qt drivers for PostgreSQL 8.x. and you will find using an DB which is about 90+% Oracle compatible a useful advantage. Don't forget PgAdmin3. If you need help getting the database going drop me a line.

                  One very neat thing about writing applications using Qt4 is that it is cross platform. With the appropriate use of compiler defines one can write code which will compile on either Linux or Windows and which will look and feel identical. That made writing software fun because writing in Linux was easier and faster than writing under Windows. Because the organization I programmed for had standardized on Oracle I was able to use PostgreSQL SQL syntax for all but a few occasions (CUBE, etc.) and had compiler defines to select between syntax variations depending on the DB being used at the time. Before compiling for production I'd set the Oracle switch on.

                  Before Qt-Creator was released I used Kate as my editor and Kdbg as my debugger. The debugging was graphical worked beautifully. Kate "almost" had auto-completion in it, a feature which Qt-Creator does very well. I say almost because Kate indexed only the current source code for previously entered words as patterns to present to you when you began typing. Qt-Creator links to the API and offers API classes, and your procedures, functions and variables in the you have used in your source before. This is handy when you can't quite remember how a class was spelled, and it offers the parameters for those classes. Auto-completion also offers the switches available for those classes and the rest.

                  After you install them you will find "Qt4 Designer", "Qt4 Assistant", "Qt4 Linguist" icons in your menu. The Designer's sole purpose is to build the GUI for your apps -- mainwindow, dialogs, widgets, etc.. The Assistant contains a graphical presentation of the Qt4 API, with examples and example coding, code snippets. The Assistant is linked to Qt-Creator and context sensitive in the source. The Linquist is the i18n part. It combines with the "tr" (translate) class to allow your app to be used in any language for which you've created word matches.

                  Doing a google search with "programming with Qt4" will show many excellent books and resources, the first listed being one I bought and would recommend. There are free programming books about Qt. Here is one...
                  http://cartan.cas.suffolk.edu/oopdocbook/opensource/
                  and here is one you can download:
                  http://rapidshare.com/files/97465542....with.Qt.4.rar

                  Don't waste your mony or time buying or reading books about Qt3, or those with only a chapter or two about Qt4. Make sure your info is FULLY devoted to Qt4.

                  I used the commercial version of Qt4 and had a support contract with Trolltech. It was well worth the money, especially since I had never programmed using either C++ or Qt before I wrote my first Qt4 program. I started using Qt just as Ver 3 was phasing out, and it was SO DIFFERENT in its approach. All coding was done with the Qt3 Designer, which was a PITA to use. I almost quite Qt but, fortunately for me, Qt4 arrived on the scene, and it returned to the more traditional C++ programming paradigm. Where Qt3 was tying me in knots, Qt4 was easy to understand and use.

                  There are two forums devoted to Qt programming:
                  http://www.qtcentre.org/
                  and
                  http://www.qtforum.org/

                  Try them both and decide which one feels best for you. I preferred the first.

                  After all, KDE4 was made using Qt4, and Qt-Creator was made for Qt4. Qt4 and Kate made the last three years of my career a total joy. If Trolletch (now QtSoftware) had released Qt-Creator four years ago I would have been in programmers heaven!

                  "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                  – John F. Kennedy, February 26, 1962.

                  Comment


                    #10
                    Re: want to learn how to program in c/c++ in linux

                    Excellent post grey geek. I had to look over my shoulder. I have been using qt, qtcreator and postgresql for the last couple weeks. Thanks for the links. I have c++ gui programming with qt4, but not the other one. I will be sure to check it out.
                    FKA: tanderson

                    Comment


                      #11
                      Re: want to learn how to program in c/c++ in linux

                      I mentioned earlier that using PostgreSQL is a good substitute for Oracle. In fact, for most medium and small businesses it is an excellent and affordable Oracle replacement. Affordable because it is free, and if support is needed it can be purchased from several support firms or EnterpriseSQL can be purchased at more reasonable prices than Oracle's per/cpu price points.

                      The following URL explains how to install and setup PostgreSQL on your computer, for local or remote access.

                      A stumbling block many new users encounter is that after they install PostgreSQL and try to use psql or PGAdmin3 they are blocked because they don't know the postgres account password, and PostgreSQL doesn't know their home account name. Catch-22.

                      Installing PostgreSQL 8.x in Kubunntu:
                      http://hocuspokus.net/2008/05/instal...-on-ubuntu-804

                      Now we need to reset the password for the ‘postgres’ admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):

                      $ sudo su postgres -c psql template1
                      template1=# ALTER USER postgres WITH PASSWORD 'password';
                      template1=# \q

                      That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:

                      $ sudo passwd -d postgres
                      $ sudo su postgres -c passwd

                      Now enter the same password that you used previously.
                      Why use template1? PostgreSQL comes with two templates, template0 and template1. Template0 "backs up" Template1. Template1 is used as the base template in creating YOUR database. Before you create your database, add to template1 all users, tables, functions, etc., that you want in ALL future databases you may create. Template0 is your backup to revert template1 back to its original state (which is identical to Template0). Typically, I add me as a superuser, and I add pglsql, python and tcl as available languages. Then I create a database with me as the owner. That way, when I log in to my account and open either psql or PGAdmin3, I am "known" by PostgreSQL. Also, I can use my db as a parent OBJECT db to create other databases, since PostgreSQL is an Object Oriented Database, where new tables can inherit columns (fields) from other tables, etc. The PostgreSQL tutorial uses weather tables to give examples of inheritance.


                      Then, from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server. But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin. Run the following at the command-line:

                      $ sudo su postgres -c psql < /usr/share/postgresql/8.3/contrib/adminpack.sql

                      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                      – John F. Kennedy, February 26, 1962.

                      Comment


                        #12
                        Re: want to learn how to program in c/c++ in linux

                        Thanks for the tips. I didn't know you could "marry" the system user to the database user. I know a little about databases, nothing about administrating them.
                        FKA: tanderson

                        Comment


                          #13
                          Re: want to learn how to program in c/c++ in linux

                          Here is an example of how to connect to a PostgreSQL database using Qt4. It is the "main.cpp" from an app called "Homestead", which keeps track of Nebraska taxpayers over 65 who are applying for property tax exemptions.

                          Code:
                          //main.cpp
                          #include <QApplication>
                          #include <QSqlDatabase>
                          #include <QSqlError>
                          #include <QMessageBox>
                          #include <QDir>
                          #include "homestead.h"
                          #include "dlglogin.h"
                          #include "wholenamedlg.h"
                          
                          #define DBDRIVER "QPSQL"
                          #define DBHOST "localhost"
                          #define DBNAME "hap2008"
                          
                          
                          int main( int argc, char * argv&#91;] ) {
                          	QString lockFileName = QDir::currentPath();
                          	lockFileName.append("/JLK_Lock.txt");
                          	QFile file(lockFileName);
                          	if (file.exists()){
                          		exit(0);
                          	}
                          	QString strRejected = "";
                          	QApplication app(argc, argv);
                          	app.setQuitOnLastWindowClosed(false);
                          	dlgLogin dlg; 
                          	if( dlg.exec() == QDialog::Accepted ){
                          		QSqlDatabase hapdb = QSqlDatabase::addDatabase(DBDRIVER);
                          		hapdb.setHostName(DBHOST);
                          		hapdb.setDatabaseName(DBNAME);
                          		hapdb.setUserName(dlg.dui.leUserName->text());
                          		hapdb.setPassword(dlg.dui.leUserPassword->text());
                          		if ( hapdb.open() ) {
                          			// The hapdb is now the default and can be accessed without reference to it
                          			// in homestead.cpp and other code. if one creates a pointer:
                          			// QSqlQuery *propQry = new QSqlQuery;
                          			// then 
                          			// propQry->exec("select proprty_id, county, countyname from property_2008");
                          			// creates a cursor with all the rows that satisfy the select because hapdb
                          			// is automatically references.
                          			// If more than one database needs to be opened simultaneously consult 
                          			// the QtSql module in the QT documentation for information
                          			// on how to do this.
                          			homestead ht;
                          			ht.RevID = dlg.dui.leUserName->text();
                          			ht.show();
                          			app.setQuitOnLastWindowClosed(true);
                          			return app.exec();
                          		} else { 
                          			strRejected = QString("Reason: %1").arg(hapdb.lastError().text()).toLatin1();
                          			QMessageBox::information(0,"Login Rejected!",strRejected,
                          			QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
                          			return 1;
                          		}
                          	} else {
                          		strRejected = QString("User Canceled the login!").toLatin1();
                          		QMessageBox::information(0,"Login Canceled!",strRejected,
                          		QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
                          		return 2;
                          	}
                          }
                          If your code complains that it can't find the database drive then you haven't installed the PostgreSQL Qt drivers from the repository. Using it is a lot easier than reconfiguring Qt4 and compiling the PostgreSQl drivers yourself, which isn't that hard, but its a PITA anyway.
                          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                          – John F. Kennedy, February 26, 1962.

                          Comment


                            #14
                            Re: want to learn how to program in c/c++ in linux

                            thank you for all your suggestions.

                            i have a dummy question (sorry! ): i've installed Qt creator, but i can't use the build or deubug options (i build from the shell as before). Why that? what i'm required to install?
                            thanks

                            Comment


                              #15
                              Re: want to learn how to program in c/c++ in linux

                              At the bottom of Qt creator there are buttons. One of the buttons is build issues. Another button is compile output. Build issues will give you the overall problems and the compile will give you the output from the compile which may contain details of problems. Post both of those back here.

                              Check under tools/options/Qt4/Qt4 versions and see if that looks correct.
                              FKA: tanderson

                              Comment

                              Working...
                              X