Qt Forum

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

    Forum Updated on Feb 6th

    Avoiding name mangling in Qt dll

    General and Desktop
    4
    8
    5513
    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.
    • I
      Indrajeet last edited by

      Hi All

      I have created a -QT- Qt Library.
      But when i try to use that dll I see the names of all the functions in dll are name mangled.

      How to avoid this?

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        first of all, which platform and which compiler tool chain do you use?

        C++ has no definitions, how names are exported. If you want to export C style functions, you have to mark this section as C

        @
        extern "C"
        {
        // my C-functions to export
        }
        @

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • I
          Indrajeet last edited by

          Hi

          below is my example code
          @class Temp
          {
          void fun1();
          void fun2();
          };@

          My above code is developed as -QT- Qt Library.
          but when I try to use extern "C" for each function it gives me error.
          Is there any keyword in QT which is equivalent to extern "C".

          1 Reply Last reply Reply Quote 0
          • G
            giesbert last edited by

            extern "C" only works for functions, not for class members. Class members will always be mangled names.

            Why do you need that?

            and you did not answer my first question:

            bq. first of all, which platform and which compiler tool chain do you use?

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply Reply Quote 0
            • I
              Indrajeet last edited by

              Hi

              I am using Visual studio 2010.
              I want to load my dll dynamically in client application.
              And use function pointers to call functions from the class.

              So wat is the solution for class members to avoid name mangling.

              1 Reply Last reply Reply Quote 0
              • G
                giesbert last edited by

                There is no. You can't load a dll dynamically and call class members idrectly, this is not possible. If you want to use classes, use a creator design pattern with interfaces or use early binding.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply Reply Quote 0
                • Z
                  ZapB last edited by

                  Name mangling is part of the C++ ABI you cannot disable it. You'll need to wrap the management of your C++ objects in plain C functions and be sure to mark those functions as extern "C" as Gerolf said.

                  Nokia Certified Qt Specialist
                  Interested in hearing about Qt related work

                  1 Reply Last reply Reply Quote 0
                  • L
                    lgeyer last edited by

                    ... and you cannot use simple functions pointers to "call methods on objects":http://www.parashift.com/c++-faq-lite/pointers-to-members.html.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post