Solved

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

Posted on 2016-11-01
1
57 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 34

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

726 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