Sign in to follow this  
elih1

convert dynamic library to static

Recommended Posts

I have an exsisting solution in Visual Studio 2005 which contains three projects. lets say them A,B,C. Two of them are confugured (A,B) to build as static libraries, and the third (C) is confugured to build as dynamic library and it links with the previous two. I changed the Configuration Type of the third project (C) to static library and specified the previous two (A,B) as its dependents. And it builds fine generating C.lib. But when I am using the C.lib library in application it gives me linking error.Note that when my library is built as dll everything works fine and I can use the library from my projects and I am not getting any linking errors. What's the problem? Where am i wrong? what should i do to generate .lib file that i can use in my projects? thank u all

Share this post


Link to post
Share on other sites

when i try to use the library as static i get the following linking error, if i use the library compiled as dynamic everything works ok.

error LNK2019: unresolved external symbol __imp__SuperAssertionW referenced in function _main .

Share this post


Link to post
Share on other sites
Well, the Error-Message says, that it doesn't find the Functionsymbol in the Library.
This problem mostly occurs, when the Preprocessor-Defintions do not match.
This often causes your code to compile because the Declaration is valid in the header, but the symbol is not compiled into the .lib.
If the BugHunter-Util is delivered as DLL you should use it as DLL or consult the Docs on how to change it to a static lib (and if its even allowed by the license).
regards

Share this post


Link to post
Share on other sites
Quote:
Original post by elih1
is it possible somehow to change something in the source code of the library and get it to work as static library?
Yes, almost certainly.
In this case you should look for (and remove) __declspec(dllexport/dllimport) declarations prefixing the library's exported symbols (e.g. functions, data or classes.)
Note that these will probably be hidden away in a macro somewhere rather than being written out explicitly each time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this