Solved

Linker errors in DLL that uses a static library that has a class with static member functions

Posted on 2016-11-01
1
48 Views
Last Modified: 2016-11-15
I am using
  VS2013 Professional C++
  Windows 7 Pro 64 bit.

I have a a library project that has two classes. Once class has all the member functions declared as virtual. The other class has its member functions declared as static. The library compiles with no errors. When I try to use the library in one of my DLL's, I can use the class that declares the functions as virtual, but I get an unresolved external linker error when I try to use the class with static functions. I own the code that has the virtual member functions, but another group in the company owns the class that has static member functions, so I cannot change it (at least not without a lot of internal effort). Any ideas how to fix this?
0
Comment
Question by:BrianDumas
1 Comment
 
LVL 33

Accepted Solution

by:
sarabande earned 500 total points
ID: 41870515
if you get unresolved externals by linker, the functions called by your code are not contained by the library you link against.

there are a few possibilities what has been wrong.

The library with the class modules was not compiled with the same Compiler or same compiler options or specifiers. for example,  import specifier __declspec(dllimport) which were set in the header files would change the internal name and your project wouldn't find the symbols in the library. You may open the library file with the hex editor of Visual Studio and search for the names missing. if there is a naming problem you should find out. if the names do not exist at all in the library, you may check if you really got the library of a library project and not an import library of a dll. if the project is ok, check whether the cpp file where the static functions were implemented really was added to the library build. if the class was a template class or the functions were template functions, the missing symbols are because template functions are compiled only if you provide a concrete type. that means in the cpp where the static functions were implemented, you need an instantiation for each template type you need in your project.  as this rarely is acceptable, the only way out, is to implement any template code as inline in the header file. then you would not need the library for those functions but by including the header, the functions were built with your project.

Sara
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now