Linking with static lib

Started by Ze, May 01, 2013, 04:31:00 PM

Previous topic - Next topic

Ze

Hi all. I'm beginner in C. I have a win32 project and a static lib, linked with it.
Up to a point it worked. Then I removed the check "Enable Microsoft extensions" and rebuild the project. I received a notices "POLINK: error: Unresolved external symbol '...'" with my lib functions names. I returned the check back, but still get this messages.
I tried to rebuild the application and the library, set different values ​​of runtime library, but nothing works, the library functions are not visible to linker.
Please help me to understand the problem.

P.S.
Sorry for my English.

----------------
I'm sorry, found one more detail. The problem occurs when I connecting two libraries to the application. If I leave one library, the functions are linking correctly. If two simultaneously - functions of one of these are not available. Can be a problem is that both of them include stdlib.h?

frankie

#1
Check that you used the correct calling convention for library and program (compiler options->calling conv.)
Rebuild libraries first than the program then link together.
Remember that a GUI program defaults to __stdcall, while a consolle application uses __cdecl. This is not mandatory, but if you don't make aware both, program and library, of what type they are the names in library are different (__cdecl simply prepend an underscore to the function name i.e _myfunc, __stdcall append a decoration indicating how many stack bytes are required for parameters i.e. _myfunc@12)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Ze

Thank you for the answer. Calling convention in both projects is __cdecl.
Problem resolved itself. I did not even know how. After some builds error is gone.
And another question:
Can I change the project type in IDE after creation? I could not find any instruments for this.
Thank you.

frankie

Actaully there is no way to do that.  :(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide