Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved] Simple initializer problem

    C++ Gurus
    5
    14
    7038
    Loading More Posts
    • 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
      Thanatos.jsse last edited by

      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 Reply Quote 0
      • M
        Mario84 last edited by

        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 Reply Quote 0
        • T
          Thanatos.jsse last edited by

          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 Reply Quote 0
          • F
            franku last edited by

            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 Reply Quote 0
            • T
              Thanatos.jsse last edited by

              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 Reply Quote 0
              • F
                franku last edited by

                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 Reply Quote 0
                • T
                  Thanatos.jsse last edited by

                  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 Reply Quote 0
                  • A
                    akonradwesolutions last edited by

                    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 Reply Quote 0
                    • T
                      Thanatos.jsse last edited by

                      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 Reply Quote 0
                      • A
                        akonradwesolutions last edited by

                        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 Reply Quote 0
                        • N
                          Neutron Stein last edited by

                          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 Reply Quote 0
                          • T
                            Thanatos.jsse last edited by

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

                            And this looks like you suggest.

                            BR,

                            1 Reply Last reply Reply Quote 0
                            • T
                              Thanatos.jsse last edited by

                              [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 Reply Quote 0
                              • T
                                Thanatos.jsse last edited by

                                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 Reply Quote 0
                                • First post
                                  Last post