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

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

    There's nothing written in build issues and in compile output. I don't know if I explained properly my problem: i can't pick neither"build" button nor "start debugging" button (nor the "run" button of course.), so no processus of building or debugging can be started. It seems as there was no compiler.

    Where should tools/options/Qt4 be?? i don't find it.
    Thanx.

    Comment


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

      Create a subdirectory called someapp (or what ever your project name is).
      Created a "main.cpp" file.
      Created someapp.h header file.
      Created your someapp.cpp file.

      Having the above files, created a project file. (somename.pro)
      In your project directory, where the above files are located, issue
      qmake -project

      That will make someapp.pro (where "someapp" is the name of the project directory in which the above files are located).

      Now, issue
      qmake someapp,pro

      This will create the Makefile (or Makefile.release and Makefile.debug, depending on the Qt configuration)

      Use QtCreator's Project menu and open the someapp.pro file. QtCreator will load the files and be ready to compile or debug.

      (Don't forget to install gdb in order to debug)
      GG





      "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


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

        thanx greygeek! forgive my ignorance... i was trying to build a c++ file without creating any project.
        Now i will try that...

        Comment


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

          Originally posted by sophmf
          thanx greygeek! forgive my ignorance... i was trying to build a c++ file without creating any project.
          Now i will try that...

          I learned C++ and Qt4 at the same time. I had started with Qt3 but within a couple months Qt4 came out. I sure was glad. Qt3's development paradigm is focused in its Designer, which was difficult to work around. Qt4 uses classic C++ development methods. The first app I wrote was designed to keep track of folks who applied to the State of Nebraska for an exemption from taxes on their home. The program was called "Homestead" and I titled my application "Hap2006", short for Homestead Application for 2006. Each year the legislature may make changes to Homesteads rules so each year had to be frozen in its own subdirectory and used as the basis for the next year, where new rules and changes to old rules could be applied to the code.

          After I wrote the application I wrote a tutorial to explain to other coders in my department how to install Qt4, configure it, and write C++ applictions using it. I posted the tutorial on QtCentre, a Qt4 watering hole. Here is the URL:
          http://wiki.qtcentre.org/index.php?t...t4_and_C%2B%2B

          You don't have to start at the first, although it might make interesting and informative reading on how things used to be done. But, with QtCreator, all the hard work of installing and configuring is done with a simple click of a button in the repository tool, which ever one you use. The actual design of Hap2006 starts at the section titled : "Using Qt4 to Write Applications" There have been many editors of this tutorial, most of whom were much smarter and skilled than I am, and they have repaired my misunderstandings, typos, and other errors. It is editable, so if you find an area which isn't clear and feel a better explanation is needed feel free to edit it and add your comments or addtions.

          I'm no expert in using Qt4 or writing C++ applications, but Qt4 made my work MUCH easier to learn and do. Previously, I had used MS Visual Studio C++ 6.0 on XP and Kate on Linux. For writing c++ software QtCreator is better than either, IMO. It makes the task MUCH quicker and more enjoyable.
          "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


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

            That's great, i'm going to read you tutorial.
            Congratulations for your work!!!!!

            Comment


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

              Originally posted by sophmf
              That's great, i'm going to read you tutorial.
              Congratulations for your work!!!!!
              My pleasure! Also, I am serious about you adding your thoughts to that tutorial. When one (me, for example) gets deep into a project they (I) don't necessarily express with sufficient clarity concepts, techniques, etc..., because they (I) assume too much.

              I began learning Qt/C++ when I was 65, and HAP2008 represents the last edition of that work, my "Magnum Opus", if you will. I retired in June of last year. As I said before, Qt4 made my last three years of programming a total joy! As testimonials often conclude, "If I can do it YOU can do it." That's especially true since I am in early "sometiimers".

              BTW, if you are going to document your work allow me to recommend Druid III, which is a Java based program designed to document databases. It works great against PostgreSQL, Oracle and about any other db you can connect to with ODBC.
              "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


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

                Naive questions from somebody who doesn't know C++ or Qt or much about the Linux internals.

                I installed the QT SDK 1.1.0 from http://www.qtsoftware.com/downloads/...-x11-32bit-cpp and had it "wizard" me a blank GUI app (onto which I dropped some random widgets).

                But I'm unsure about the libraries. libQtGui, for example:

                /opt/qtsdk-2009.02/lib/libQtGui.so.4.5.1 (11.6 MiB)
                /opt/qtsdk-2009.02/qt/lib/libQtGui.so.4.5.1 (86.9 MiB)
                /usr/lib/libQtGUI.so.4.5.0 (9.9 MiB)

                Why the radically different sizes?
                Which version would my projects be compiled against? (Is that even a meaningful question?) Under Tools -> Options, only the installation of QT in /usr is listed as autodetected, so I suppose my super GUI app uses that set of .so files (inasmuch as it needs them)...?
                What is the purpose of those other lib directories in /opt/qtsdk-2009.02? In case QT isn't already installed on the OS? As far as I can tell /opt/qtsdk-2009.02/lib/ is used by the QT-Creator application itself, for itself...?
                Where could I start learning more about this?

                Comment


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

                  You are going about it the hard way, unless you really want to run Qt4's "configure" app and tell it in great detail how you want Qt4's dev tools configured. Consult the online QT4 API documentation for what "configure" does and how to use it.

                  The EASY way is to remove the SDK you downloaded from QtSoftware and take advantage of the Kubuntu dev team, which did the configuration work and set up Qt4 to allow the creation of both static and dynamic apps, including debugging. They put their work in the repository. You can access it by downloading the following Qt 4.5.0-Oubuntu4.1 files:
                  qt4-demos
                  qt4-designer
                  qt4-dev-tools
                  qt4-dev-tools-dlg
                  qt4-doc
                  qt4-qmake
                  qt4-qtconfig
                  qt-creator
                  libqtcore4
                  libqtgui4
                  and everything that starts with "libqt4-", most of which should be automatically selected when you select the files above. If you use python you may want some of the python-qt4-* files, but many will already be selected because of other apps you installed. (KDE4 is made by Qt4, after all).
                  This will put the demos, examples and plugins under /usr/lib/qt4. The libraries of the GUI RAD, qt-creator, will be under /usr/lib/qtcreator. The Qt4 library files are in directories under /usr/include/qt4. They include Qt, qt3 support, QtAssistant, QtCore, QtDBus, QtDesign QtGui, QtSql, and a host of others.

                  Qt4's main directory is /usr/share/qt4. Under it are
                  bin/, which contains the Qt4 binaries: designer, moc, rcc, uic, qmake, lrelease and lupdate; doc/, which contains the obvious...
                  include/, which contains the QT4 class headers and defs
                  lib/, which contains the libQt*.so.4.5.0 library files
                  mkspecs/, which contains the Qt4 platform specification files ("default" is linked to linux-g++)
                  and a couple of other directories.

                  Also under /usr/share/ is /usr/share/qtcreator. Under it are
                  designer/, which contains the Qtcfreator UI forms,
                  gdbmacros/, which contains the debugger project file and cpp file for qtcreator's gdbmacros app
                  and two other directories, snippets and templates, under which is the qt4project headers and cpp files.

                  Also install gdb and kdbg. If you are going to database work the best one you can use, IMO, is PostgreSQL 8.x, with PgAdmin3 as its GUI admin app. In an answer to another question about programming in Linux I posted how to install and configure PostgreSQL.
                  http://kubuntuforums.net/forums/inde...opic=3100874.0





                  "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


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

                    Thanks for the explanations. I don't really want to mess about much; I'm not sure I can make the room in my mind right now to learn C++, but it seems I'm always poking around anyway. I had downloaded the SDK because I was hoping a newer version of Qt-Creator might have overcome some minor, cosmetic not-really-bugs. The problems are still there -- so I might as well revert to the package from the repositories...

                    ...but then I just wanted to get some sort of grip on the "library thing"! I just don't like feeling so lost when it comes to Linux basics like libraries. (For a real world example (not Qt specific): If I compile an app that, among other things, uses the "SDL mixer" library, and give the resulting binary to somebody whose distribution uses an older version of the same library, will it run? Would it have to be recompiled? And wasn't there a command that listed the libraries a program expected to use? I forgot. I think I'll install another Linux or two on VirtualBox to, well, mess about.)

                    Comment


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

                      If I compile an app that, among other things, uses the "SDL mixer" library, and give the resulting binary to somebody whose distribution uses an older version of the same library, will it run?
                      Yes, for Qt libs, because QtSoftware (formerly Trolltech) controls the libraries. Good coders can add functions to an existing library without messing up the library jump table or breaking functions previously in the library. Bad programmers usually either mess up the jump table, pointing a function call to the wrong location or a bad location, or they change the parameters a function expects to see, breaking it, or both.

                      So, if you have somelib.so.1.2 in your library, and a good coder adds a function to it, required by his new software, and releases the new library as somelib.so.1.3, so you now have two similar libraries in your system. This is not a problem because previously existing programs that used somelib.so.1.2 called it by calling somelib.so.0, which is linked to somelib.so.1.2.

                      The installation program for the new software installs somelib.so.1.3, deletes the old link, and creates a new link by the same name, but linking to the new library: somelib.so.0 --> somelib.so.1.3. Because the code honored the original jump table and function signatures, previous applications needing somelib still work. Additions to the library jump table, and added functions to the new library allow the new software to work.
                      "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


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

                        Hmmm. I think I meant "the other direction", from new to old.

                        1) I compile someapp on my system. Someapp only runs when somelib is present. My system happens to have somelib 1.3 installed (default from repositories).
                        2) Then I give the compiled someapp binaries to somebody whose system only has somelib 1.2.
                        3) I know someapp can be compiled and will run on a system with somelib 1.2, because I used to do just that back when I was running Gutsy or Hardy or whatever.
                        4) But can someapp run on a system with somelib 1.2 when it was compiled on another system, one with a newer version of somelib?

                        Note that I'm talking about distributing a plain .tar.gz file whose contents could be "pasted" directly into the /usr branch, not about a distribution-specific deb or rpm (etc.) package or an installer that'd take care of dependencies.

                        Thanks

                        Comment


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

                          Originally posted by sophmf
                          where I can download Qt creator? i don't find it in the repos.
                          Thanx!
                          It IS present. It is called qt-creator.
                          "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

                          Working...
                          X