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. Can not Find Functions In Static Library

Can not Find Functions In Static Library

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlounge
10 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.
  • A Offline
    A Offline
    AmbiguousName
    wrote on last edited by
    #1

    hello guys... This error has something to do with linking. I have a static library (which contains some virtual functions) and I have taken following steps to add it to my project. - Project Name -> Add -> Existing Item . Chose and included header file. - Project Name -> Properties -> C/C++ -> General -> Additional Include Directories. Navigated to the folder containing the header file. - Project Name -> Properties -> Linker -> Input -> Additional Dependencies . Gave the path including the library_name.lib Until here, it compiles successfully. But when I derive a class from a class in this header file, it starts giving this error like: Error LNK 2001 - Unresolved External Symbols? Whats wrong with this approach? Thanks for any input.

    This world is going to explode due to international politics, SOON.

    C A 2 Replies Last reply
    0
    • A AmbiguousName

      hello guys... This error has something to do with linking. I have a static library (which contains some virtual functions) and I have taken following steps to add it to my project. - Project Name -> Add -> Existing Item . Chose and included header file. - Project Name -> Properties -> C/C++ -> General -> Additional Include Directories. Navigated to the folder containing the header file. - Project Name -> Properties -> Linker -> Input -> Additional Dependencies . Gave the path including the library_name.lib Until here, it compiles successfully. But when I derive a class from a class in this header file, it starts giving this error like: Error LNK 2001 - Unresolved External Symbols? Whats wrong with this approach? Thanks for any input.

      This world is going to explode due to international politics, SOON.

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      I'm not sure, but the specification of Additional Dependencies may only affect the bulding and re-building of your project. I think you have to specify additional linker directories to use and also additional libraries to include. This are usually in the same place or tab as the Additional Dependencies. :)

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

      1 Reply Last reply
      0
      • A AmbiguousName

        hello guys... This error has something to do with linking. I have a static library (which contains some virtual functions) and I have taken following steps to add it to my project. - Project Name -> Add -> Existing Item . Chose and included header file. - Project Name -> Properties -> C/C++ -> General -> Additional Include Directories. Navigated to the folder containing the header file. - Project Name -> Properties -> Linker -> Input -> Additional Dependencies . Gave the path including the library_name.lib Until here, it compiles successfully. But when I derive a class from a class in this header file, it starts giving this error like: Error LNK 2001 - Unresolved External Symbols? Whats wrong with this approach? Thanks for any input.

        This world is going to explode due to international politics, SOON.

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

        This looks like it should work... in the header that you have included, make sure you don't have to #define anything to specify that you are using the library instead of building it. Sometimes developers use the same exact header file to build the library than what others would use to import the library and just use pre-processor directives to tell the difference. What are the external symbols that it can't find? Are they defined in the header?

        A 1 Reply Last reply
        0
        • A Albert Holguin

          This looks like it should work... in the header that you have included, make sure you don't have to #define anything to specify that you are using the library instead of building it. Sometimes developers use the same exact header file to build the library than what others would use to import the library and just use pre-processor directives to tell the difference. What are the external symbols that it can't find? Are they defined in the header?

          A Offline
          A Offline
          AmbiguousName
          wrote on last edited by
          #4

          Albert Holguin wrote:

          What are the external symbols that it can't find? Are they defined in the header?

          Yes. They are virtual functions and are defined in the header file.

          This world is going to explode due to international politics, SOON.

          C 1 Reply Last reply
          0
          • A AmbiguousName

            Albert Holguin wrote:

            What are the external symbols that it can't find? Are they defined in the header?

            Yes. They are virtual functions and are defined in the header file.

            This world is going to explode due to international politics, SOON.

            C Offline
            C Offline
            Chuck OToole
            wrote on last edited by
            #5

            Regular "virtual" or "pure virtual"? Makes a difference. Please post the definition from the header file so we can see.

            A 1 Reply Last reply
            0
            • C Chuck OToole

              Regular "virtual" or "pure virtual"? Makes a difference. Please post the definition from the header file so we can see.

              A Offline
              A Offline
              AmbiguousName
              wrote on last edited by
              #6

              Well they are regular virtual functions. An example of them can be like this

              virtual void OnAdd(double n1, double n2);
              virtual void OnSub(double n1, double n2);
              virtual void OnMul(double n1, double n2);
              virtual void OnMul(double n1, double n2);

              Now I have implemented a similar application whose architecture is exactly same. Four arithmetic virtual functions in a library which I later included in the project. Then I derived a class from this lib's class and overrided those functions. It worked successfully.

              This world is going to explode due to international politics, SOON.

              C 1 Reply Last reply
              0
              • A AmbiguousName

                Well they are regular virtual functions. An example of them can be like this

                virtual void OnAdd(double n1, double n2);
                virtual void OnSub(double n1, double n2);
                virtual void OnMul(double n1, double n2);
                virtual void OnMul(double n1, double n2);

                Now I have implemented a similar application whose architecture is exactly same. Four arithmetic virtual functions in a library which I later included in the project. Then I derived a class from this lib's class and overrided those functions. It worked successfully.

                This world is going to explode due to international politics, SOON.

                C Offline
                C Offline
                Chuck OToole
                wrote on last edited by
                #7

                I hate to ask a question that should have been asked first. What is the exact error message. Which "symbol" is unresolved, the one in the base class or the one in your derived class? If it's the former, then the problem is that your library is not included in the linker section as an additional library. If it's the latter, then the problem is in your code and the definition of the overridden members.

                A 1 Reply Last reply
                0
                • C Chuck OToole

                  I hate to ask a question that should have been asked first. What is the exact error message. Which "symbol" is unresolved, the one in the base class or the one in your derived class? If it's the former, then the problem is that your library is not included in the linker section as an additional library. If it's the latter, then the problem is in your code and the definition of the overridden members.

                  A Offline
                  A Offline
                  AmbiguousName
                  wrote on last edited by
                  #8

                  That's in base class. But it is solved by strange method. What I did is: - I overrided all the virtual functions in the the derived class (although left function bodies blank :) ). This solved my problem. But I am thinking why it should have been a problem. I mean usually virtual functions are meant to be overriden, what if I don't want to override them at a particular point. Well it is becoming messy, I am happy that my problem is solved for now.

                  This world is going to explode due to international politics, SOON.

                  C 1 Reply Last reply
                  0
                  • A AmbiguousName

                    That's in base class. But it is solved by strange method. What I did is: - I overrided all the virtual functions in the the derived class (although left function bodies blank :) ). This solved my problem. But I am thinking why it should have been a problem. I mean usually virtual functions are meant to be overriden, what if I don't want to override them at a particular point. Well it is becoming messy, I am happy that my problem is solved for now.

                    This world is going to explode due to international politics, SOON.

                    C Offline
                    C Offline
                    Chuck OToole
                    wrote on last edited by
                    #9

                    You didn't "solve" the problem, you only made the "symptoms" go away. Now you have empty functions overriding ones that may have done something useful, as you've discovered. If it can't find the functions in the library then: 1) you didn't list the library as an input to the linker (both debug and release) 2) you are feeding in the wrong library 3) they are not in the library You need to go back to the person / source that gave you the library and ask them about the contents and why you are having this particular problem. I'm going to stop offering suggestions on this one.

                    A 1 Reply Last reply
                    0
                    • C Chuck OToole

                      You didn't "solve" the problem, you only made the "symptoms" go away. Now you have empty functions overriding ones that may have done something useful, as you've discovered. If it can't find the functions in the library then: 1) you didn't list the library as an input to the linker (both debug and release) 2) you are feeding in the wrong library 3) they are not in the library You need to go back to the person / source that gave you the library and ask them about the contents and why you are having this particular problem. I'm going to stop offering suggestions on this one.

                      A Offline
                      A Offline
                      AmbiguousName
                      wrote on last edited by
                      #10

                      As I stated earlier, I made a similar application (calculator) with exactly same architecture and it worked. Well I did ask him. But that poor guy could not answer me. He could only give a possible solution that was: may be its due to the character set. - The library was made using: Not Set. - While my solution was made using: Use Unicode Character set. But he was not sure what the problem could be. Anyway, thank you very much for your time.

                      This world is going to explode due to international politics, SOON.

                      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