Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Solved] Simple initializer problem

[Solved] Simple initializer problem

Scheduled Pinned Locked Moved C++ Gurus
14 Posts 5 Posters 7.7k 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.
  • T Offline
    T Offline
    Thanatos.jsse
    wrote on last edited by
    #1

    Hi,

    I am developing a Qt program with three libraries, but when compile the project, compiler return a error:

    In file included from ../../../Sipred/src/app/core.h:32:0,
    _ from ../../../Sipred/src/app/main.cpp:29:_
    ../../../Sipred/src/managers/interface/interfacemngr.h:38:42: error: expected initializer before ':' token
    make[ 2 ]: *** [../../.obj/release/main.o] Error 1

    But I can't see anything wrong with that. If someone can take a look in my source code and give me advice about this problem I'll acknowledge.

    Source code can be found at: "link":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/interface/interfacemngr.h

    BR,

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mario84
      wrote on last edited by
      #2

      I'm not sure if this is the problem, but:
      You declared InterfaceMngr as follows:

      [code]
      class INTERFACEMNGR_EXPORT InterfaceMngr : public QObject
      [/code]

      ...but the symbol INTERFACEMNGR_EXPORT isn't always defined:

      [code]
      #if defined(INTERFACEMNGRLIB_LIBRARY)

      define INTERFACEMNGR_EXPORT Q_DECL_EXPORT

      #else

      define INTERFACEMNGR_IMPORT Q_DECL_IMPORT

      #endif
      [/code]

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thanatos.jsse
        wrote on last edited by
        #3

        Hi Mr. Universe,

        Thank you for answer, but I define the simbol using my *.pro file:

        @# interface_mngr.pro
        DEFINES +=
        INTERFACEMNGRLIB_LIBRARY@

        I thought that at the beginning, but ....

        Best regards,

        1 Reply Last reply
        0
        • F Offline
          F Offline
          franku
          wrote on last edited by
          #4

          Additionally you could run qmake again.

          If you want to be clear which code is used by the preprocessor you want to use a statement like this:

          @#error "Simple"@

          But I don't understand why you define the EXPORT and the IMPORT macro when using only the EXPORT in your class definition.

          This, Jen, is the internet.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Thanatos.jsse
            wrote on last edited by
            #5

            Hi franku,

            You are right, but DEFINES qmake adds the values of this variable as compiler C preprocessor macros (-D option). So, when I add the line:
            @# interface_mngr.pro
            DEFINES +=
            INTERFACEMNGRLIB_LIBRARY@

            it add

            @#define INTERFACEMNGRLIB_LIBRARY@

            Thank you for your time.

            PD: When create shared lib follow this "link":http://doc.qt.nokia.com/4.7-snapshot/sharedlibrary.html#header-file-considerations

            1 Reply Last reply
            0
            • F Offline
              F Offline
              franku
              wrote on last edited by
              #6

              Hi, I know. This is the reason why I asked you to rebuild your makefiles using qmake. Just to be shure having the -D commandline parameter being passed to the compiler. Read the contents of the link again carefully to see where the difference is to your code.

              You can use the #error to stop the preprocessor if you want to know which line is really evaluated.

              This, Jen, is the internet.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Thanatos.jsse
                wrote on last edited by
                #7

                I have found a strange issue:

                I delete all references to InterfaceMngr in the file core.h and core.cpp, and found that the library compile without errors, but when I try to use it, give the compile error referenced here before.

                BR,

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  akonradwesolutions
                  wrote on last edited by
                  #8

                  Shouldn't it be:

                  @
                  #if defined(INTERFACEMNGRLIB_LIBRARY)

                  define INTERFACEMNGR_EXPORT Q_DECL_EXPORT

                  #else

                  define INTERFACEMNGR_EXPORT Q_DECL_IMPORT

                  #endif
                  @

                  otherwise, INTERFACEMNGR_EXPORT will not be defined when you try to use the exported symbol.

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Thanatos.jsse
                    wrote on last edited by
                    #9

                    Hi Arnold,

                    I have other two similars definitions but don't have any problem.
                    The libraries "ModuleMngr":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/module/modulemngr.h and "PluginMngr":https://github.com/thanatosJSSE/Sipred/blob/master/src/managers/plugin/pluginmngr.h.

                    Thank you.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      akonradwesolutions
                      wrote on last edited by
                      #10

                      In both pluginmngr_global.h and modulmngr_global.h the declaration looks like this

                      @
                      #ifndef PLUGINMNGR_GLOBAL_H
                      #define PLUGINMNGR_GLOBAL_H

                      #include <QtCore/QtGlobal>

                      #if defined(PLUGINMNGRLIB_LIBRARY)

                      define PLUGINMNGR_EXPORT Q_DECL_EXPORT

                      #else

                      define PLUGINMNGR_EXPORT Q_DECL_IMPORT

                      #endif

                      #endif // PLUGINMNGR_GLOBAL_H
                      @

                      which is exactly what i suggested.

                      Regards,
                      Arnold

                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        Neutron Stein
                        wrote on last edited by
                        #11

                        If i am not wrong there is a missing ";" after Q_DECLARE_PRIVATE(InterfaceMngr):
                        @
                        private:
                        Q_DECLARE_PRIVATE(InterfaceMngr) ; //here

                        };
                        @

                        Never Seen !

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          Thanatos.jsse
                          wrote on last edited by
                          #12

                          That's right, interfacemngr have his own interfacemngr_global.h.

                          And this looks like you suggest.

                          BR,

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            Thanatos.jsse
                            wrote on last edited by
                            #13

                            [quote author="Neutron Stein" date="1343136256"]If i am not wrong there is a missing ";" after Q_DECLARE_PRIVATE(InterfaceMngr):
                            @
                            private:
                            Q_DECLARE_PRIVATE(InterfaceMngr) ; //here

                            };
                            @[/quote]

                            There is no problem, I tried that too, without results.
                            I found that this library is compiled, but when I try to use it give me that error.

                            1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              Thanatos.jsse
                              wrote on last edited by
                              #14

                              Ok,

                              Thank everyone that helped me to take a look to mi code.
                              Well the problem was a personal mistake:

                              @#if defined(INTERFACEMNGRLIB_LIBRARY)

                              define INTERFACEMNGR_EXPORT Q_DECL_EXPORT

                              #else

                              define INTERFACEMNGR_IMPORT Q_DECL_IMPORT <---- ERROR!!!

                              #endif@

                              Must be EXPORT like Arnold said

                              BR,

                              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