Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Calling C Function in Dll Causing Problem

Calling C Function in Dll Causing Problem

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 4 Posters 0 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    Django_Untaken
    wrote on last edited by
    #1

    Hello there. I am trying to call a C function in my newly created Dll project's code. But doing so produces Unresolved External Symbol error. Here is the what I am trying

    Header.h

    int call_main(int argc, char** argv);

    Header.cpp

    int call_main(int argc, char** argv)
    {
    // all the code here .....
    return 0;
    }

    Now I include this Header.h in my Dll's main file and try to call call_main. Building the project produces the said error.

    #include "Header.h"

    class Functions
    {
    public:
    static __declspec(dllexport) int Call_MyMain(char **argv);
    };

    int Functions::Call_MyMain(char **argv)
    {
    return call_main(8, argv); // HERE I AM CALLING FROM ABOVE HEADER FILE
    }

    What could be wrong? What am I missing? Thanks for any input.

    L 1 Reply Last reply
    0
    • D Django_Untaken

      Hello there. I am trying to call a C function in my newly created Dll project's code. But doing so produces Unresolved External Symbol error. Here is the what I am trying

      Header.h

      int call_main(int argc, char** argv);

      Header.cpp

      int call_main(int argc, char** argv)
      {
      // all the code here .....
      return 0;
      }

      Now I include this Header.h in my Dll's main file and try to call call_main. Building the project produces the said error.

      #include "Header.h"

      class Functions
      {
      public:
      static __declspec(dllexport) int Call_MyMain(char **argv);
      };

      int Functions::Call_MyMain(char **argv)
      {
      return call_main(8, argv); // HERE I AM CALLING FROM ABOVE HEADER FILE
      }

      What could be wrong? What am I missing? Thanks for any input.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to include the object module of header.cpp inside the build of your dll.

      D 1 Reply Last reply
      0
      • L Lost User

        You need to include the object module of header.cpp inside the build of your dll.

        D Offline
        D Offline
        Django_Untaken
        wrote on last edited by
        #3

        I don't know what does this mean? How do I do that?

        A L 2 Replies Last reply
        0
        • D Django_Untaken

          I don't know what does this mean? How do I do that?

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          ...means your dll project should be building header.cpp... which produces an object file.

          D 1 Reply Last reply
          0
          • D Django_Untaken

            I don't know what does this mean? How do I do that?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You add it to the project just as you would any other module. See Walkthrough: Creating and Using a Dynamic Link Library (C++)[^].

            1 Reply Last reply
            0
            • A Albert Holguin

              ...means your dll project should be building header.cpp... which produces an object file.

              D Offline
              D Offline
              Django_Untaken
              wrote on last edited by
              #6

              It is building header.cpp and it also produces an object file

              A 1 Reply Last reply
              0
              • D Django_Untaken

                It is building header.cpp and it also produces an object file

                A Offline
                A Offline
                Albert Holguin
                wrote on last edited by
                #7

                If you actually compiled one as C and the other as C++ (or the other way around), you'll also have to deal with name mangling... Standard C++[^] If they're both C++, it's actually still possible to screw up the mangling, I believe Studio allows you to set the mangling mode to each file independently (haven't used Studio in a while though). Decorated Names[^]

                M 1 Reply Last reply
                0
                • A Albert Holguin

                  If you actually compiled one as C and the other as C++ (or the other way around), you'll also have to deal with name mangling... Standard C++[^] If they're both C++, it's actually still possible to screw up the mangling, I believe Studio allows you to set the mangling mode to each file independently (haven't used Studio in a while though). Decorated Names[^]

                  M Offline
                  M Offline
                  mariakatosvich
                  wrote on last edited by
                  #8

                  i think You need to include the object module of header.cpp inside the build of your dll.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups