?
Solved

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

Posted on 2016-11-01
1
Medium Priority
?
79 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
sarabande earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

770 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