Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Issues compiling c files in Qt creator
QtWS25 Last Chance

Issues compiling c files in Qt creator

Scheduled Pinned Locked Moved Installation and Deployment
28 Posts 8 Posters 21.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benardmens
    wrote on last edited by
    #1

    I'm learning c/c++ and wanted to do some work with QT Creator. I am using a base64 class that just refuses to compile and any help would be greatly appreciated.

    The error lines I get is
    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.h:59: error: expected ';', ',' or ')' before 'in'

    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.h:66: error: expected ';', ',' or ')' before 'in'

    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.c:68: error: expected ';', ',' or ')' before 'in'

    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.c:: error: At top level:

    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.c:320: error: expected ';', ',' or ')' before '*' token

    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.c:373: error: expected ';', ',' or ')' before 'in'
    /QTDev/PolicyFrameworkDesktop-build-desktop/../PolicyFrameworkDesktop/libhaggle/base64.c:456: error: expected ';', ',' or ')' before 'in'

    The files in question are in the links below along with the 'pro' file and the generated Makefile.

    http://rapidshare.com/files/435084121/base64.c
    http://rapidshare.com/files/435084122/base64.h
    http://rapidshare.com/files/435084571/Makefile
    http://rapidshare.com/files/435084682/PolicyFrameworkDesktop.pro

    [fixed topic, Tobias Hunger]

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      restrict is C keyword, not C++. I think you should not include them in .pro but make additional Makefile (manually) which will call C compiler for base64 library and link it in your .pro file.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        benardmens
        wrote on last edited by
        #3

        Hi Denis,

        Thanks for the quick reply. Can you please give me an example of how to link a manual makefile to a pro file? Also i thought the #ifdef __cplusplus section would stop any compiler issues?

        Thanks again

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          Why a base64 library? Qt can de/encode base64 all by itself (QByteArray::fromBase64 and toBase64).

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DenisKormalev
            wrote on last edited by
            #5

            You can add it as custom target to PRE_TARGETDEPS variable I think.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              benardmens
              wrote on last edited by
              #6

              [quote author="Tobias Hunger" date="1291577543"]Why a base64 library? Qt can de/encode base64 all by itself (QByteArray::fromBase64 and toBase64).[/quote]

              Hi Toby,
              Thanks for the reply, that class is part of the source of a library that I am trying to use. It builds fine when running a normal gcc session from the command line so I was a bit surprised when I run into the issue. I'm not a c++ expert by any stretch ,just learning as I go along, but if I understand what you are suggesting it means that I have to go through the whole library replacing the instances of base64 calls with the QByteArray calls, and I don't know how that will affect the rest of the library which was why I wanted to see if there was something I should be doing instead.

              Thanks again

              1 Reply Last reply
              0
              • B Offline
                B Offline
                benardmens
                wrote on last edited by
                #7

                [quote author="Denis Kormalev" date="1291577718"]You can add it as custom target to PRE_TARGETDEPS variable I think.
                [/quote]

                Thanks for that Denis, will try that right away and let you know how it goes.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  benardmens: Oh, if this is part of 3rd party code then forget my comment.

                  Many people seem to not know that Qt can de/encode base64 all by itself... I have seen more than one piece of code where some developer dragged in a 3rd party library just to write some bytes in base64 encoding.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    Unfortunately I cannot download the files (too many downloads in parallel). So, sorry, can't help with this.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      benardmens
                      wrote on last edited by
                      #10

                      [quote author="Denis Kormalev" date="1291577718"]You can add it as custom target to PRE_TARGETDEPS variable I think.
                      [/quote]

                      Hi Denis, tried that but it didn't work. The way I understood it is to add a custom Makefile argument to the PRE_TARGETDEPS? Thanks

                      [edit: quoe fixed / Denis Kormalev]

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        benardmens
                        wrote on last edited by
                        #11

                        [quote author="Volker" date="1291582514"]Unfortunately I cannot download the files (too many downloads in parallel). So, sorry, can't help with this.[/quote]

                        Hi Volker,
                        These are some new links which shouldnt give the same problem,

                        http://www.mediafire.com/?z13ki4t48iqs8ke
                        http://www.mediafire.com/?nq14e8527bj4l7i
                        http://www.mediafire.com/?1a23rh9ngxpe3dm

                        I would appreciate any help as I've been trying to get this working for a day now. Thanks again

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          DenisKormalev
                          wrote on last edited by
                          #12

                          benardmens, can you show your .pro file (please post its content here in @ tags)?

                          1 Reply Last reply
                          0
                          • X Offline
                            X Offline
                            xsacha
                            wrote on last edited by
                            #13

                            You could put the files inside a zip or tar. Makes it easier to upload and download (for future reference).

                            Theres a site called wikiupload that doesn't have a time delay to download.

                            • Sacha
                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              benardmens
                              wrote on last edited by
                              #14

                              [quote author="Denis Kormalev" date="1291620464"]benardmens, can you show your .pro file (please post its content here in (at) tags)?[/quote]

                              Hi Denis,
                              I just got a work around to work by building it as a library and adding it manually to the libs. However , i would still like to be able to understand how to do it properly if possible.

                              The current .pro file is below as requested

                              @
                              #-------------------------------------------------

                              Project created by QtCreator 2010-12-05T20:36:45

                              #-------------------------------------------------

                              QT += core gui

                              TARGET = PolicyFrameworkSpy
                              TEMPLATE = app

                              unix:LIBS +=-L/usr/include/libxml2
                              /usr/local/lib/libhaggle.a

                              unix:INCLUDEPATH +=/usr/local/include/libhaggle/
                              /usr/include/libxml2 \

                              QMAKE_CFLAGS_DEBUG += -std=gnu99 -O2
                              QMAKE_LFLAGS += -lxml2 -lz -lpthread -licucore -lm
                              SOURCES += main.cpp
                              PolicyFramework.cpp

                              HEADERS += PolicyFramework.h

                              FORMS += PolicyFramework.ui
                              @

                              And the one I was having issues with

                              @
                              #-------------------------------------------------

                              Project created by QtCreator 2010-12-05T16:43:38

                              #-------------------------------------------------

                              QT += core gui

                              TARGET = PolicyFrameworkDesktop
                              TEMPLATE = app

                              INCLUDEPATH +=/QTDev/PolicyFrameworkDesktop/libhaggle

                              SOURCES += main.cpp
                              PolicyFrameworkSpy.cpp
                              libhaggle/base64.c

                              HEADERS += PolicyFrameworkSpy.h
                              libhaggle/base64.h

                              FORMS += PolicyFrameworkSpy.ui
                              @

                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                benardmens
                                wrote on last edited by
                                #15

                                [quote author="xsacha" date="1291620625"]You could put the files inside a zip or tar. Makes it easier to upload and download (for future reference).

                                Theres a site called wikiupload that doesn't have a time delay to download.[/quote]

                                Thanks for that, I will keep that in mind for later. Thanks for the help everyone. This is one of the most responsive forums I've ever been on!

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  DenisKormalev
                                  wrote on last edited by
                                  #16

                                  benardmens, try to add something like this
                                  @
                                  someLib.target = someLibBuild
                                  someLib.commands = cd path/to/lib && make
                                  QMAKE_EXTRA_TARGETS += someLib
                                  PRE_TARGETDEPS += someLibBuild
                                  @

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on last edited by
                                    #17

                                    [quote author="benardmens" date="1291619302"]
                                    These are some new links which shouldnt give the same problem,

                                    I would appreciate any help as I've been trying to get this working for a day now. Thanks again[/quote]

                                    I put base64.h and and base64.c in a small project and could compile it and use its base64_encode_alloc in a C++ program.

                                    qmake calls g++ or gcc depending on the file extension (cpp or c). I used no pre targets or libs or something like that.

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      maciej
                                      wrote on last edited by
                                      #18

                                      Hi all,
                                      1st thing is that you are not using class. There is no such thing in C as class or object!
                                      Your problem is that you're using qt tools to compile (.pro file & qmake) which generate Makefiles only for C++. If you want to compile C code with QtCreator you should start using "cmake":http://cmake.org/ (which is supported by QtCreator) instead of .pro files.

                                      Earth is a beta site.

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on last edited by
                                        #19

                                        Not quite true.

                                        @
                                        HEADERS += plain.h base64.h
                                        SOURCES += main.cpp base64.c
                                        @

                                        This calls g++ (GCC in C++ mode) on main.cpp and gcc (GCC in C mode) on base64.c. The decision is made on the file extension (.cpp or .c). One can tweak that with setting QMAKE_EXT_CPP. The default is .cpp .cc .cxx .C

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • G Offline
                                          G Offline
                                          GordonSchumacher
                                          wrote on last edited by
                                          #20

                                          Actually, there's an even better way:

                                          Top-level .pro file:
                                          @
                                          TEMPLATE = subdirs

                                          someLib.subdir = someLib
                                          someLib.makefile = someLib.mak # This may not be named "Makefile"!
                                          someLib.target = $${QMAKE_PREFIX_SHLIB}someLib.${QMAKE_EXTENSION_SHLIB}

                                          SUBDIRS = someLib someApp
                                          @

                                          someLib/someLib.mak:
                                          @
                                          libsomeLib.so:
                                          gcc foo.c -o libsomeLib.so

                                          clean:
                                          rm -f libsomeLib.so

                                          distclean: clean

                                          .PHONY: clean distclean
                                          @

                                          Note that it will create a bogus, non-functional "someLib/Makefile", but you may simply ignore it.

                                          I don't believe this is documented, but it's been in qmake for quite a long time (I want to say at least since 4.3.x, but don't quote me on that).

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved