opc0d3 Posted April 26, 2022 Posted April 26, 2022 (edited) Can't use a .lib from vc6 that has no source. Keep getting this error of "unresolved external" _set_new_handler. Already installed all CRT from VSTUDIO. Universal CRT. And so on. Tried to include this libs in the project, seems that none of them can solve the issue. https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170 Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol "int (__cdecl*__cdecl _set_new_handler(int (__cdecl*)(unsigned int)))(unsigned int)" (?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z) MODULE LIB_LOCATION...(Exception.obj) I'm thinking in reverse it into code. It's not TOO long, but if there is a way to solve without reversing it is better. I've tried to include another obj that uses this function _set_new_handler in it's code hoping that Exception.obj would find this reference and use it.. But it was all in vain. Can anyone help me with it ? Edited May 19, 2022 by opc0d3
kao Posted April 26, 2022 Posted April 26, 2022 Better question is - why do you want to link VC6 .lib into your VS2019 project? VS2019 has its own lib (libcpmt*.lib) that implements _set_new_handler, you should use that. 1
opc0d3 Posted April 27, 2022 Author Posted April 27, 2022 3 hours ago, kao said: Better question is - why do you want to link VC6 .lib into your VS2019 project? VS2019 has its own lib (libcpmt*.lib) that implements _set_new_handler, you should use that. I trying to make an old VC6 solution/project to compile in modern VS2019 and c++; This specific lib doesn't has source.. So I'm stuck with it. Until I do reverse engineer it and rewrite. But for now I'm interested in adapt to compile the project. I have included this lib also. libcpmt.lib.. Still nothing.. Same error. I don't know what happens.. It seems so simple, yet so complex. Why does the linker can't find the symbol if it is there.. Just doesn't make any sense. However if I do uses _set_new_handler in a new compiled program it works just fine. I was wondering if is the function definition that maybe is different. How would be the proper way to overload this function using/exporting into a new .lib ? I mean.. _set_new_handler = ULONG _set_new_header...... you know ? Uses the same definition that it generating the error in the first place.
atom0s Posted May 1, 2022 Posted May 1, 2022 Microsoft made a translation layer lib for older CRT compiled libraries to be compatible with newer versions of VS. You can try and see if it helps in your situation. Add an import to the library: legacy_stdio_definitions.lib You can do this either via a direct #pragma call like: #pragma comment(lib, "legacy_stdio_definitions.lib") Or you can add it directly in the project settings under: Linker -> Input -> Additional Dependencies 1
opc0d3 Posted May 3, 2022 Author Posted May 3, 2022 (edited) On 5/1/2022 at 4:28 PM, atom0s said: Microsoft made a translation layer lib for older CRT compiled libraries to be compatible with newer versions of VS. You can try and see if it helps in your situation. Add an import to the library: legacy_stdio_definitions.lib You can do this either via a direct #pragma call like: #pragma comment(lib, "legacy_stdio_definitions.lib") Or you can add it directly in the project settings under: Linker -> Input -> Additional Dependencies Hello, atom0s.. Thanks for your reply. I don't know if it would resolve it, I've been able to solve it. Using nasm.. I just used the name that my old lib was asking and put it to function export. Used NASM, LINK (VC++) and LIB (VC++). I generated a LIB that satisfies the Link in the project. Because I already has the LIB and DLL for this importation. Well I think that I have a road to compile it. It resolved for now. Since this project is OLD and I'm trying to "mordernize" it to new c++ version and API importation, it's been a really pain to compile the project that I want from this solution (.sln). I already fix the code part. Now it been a pain to link everything. I've been trying to compile using this LIB, legacy_stdio_definitions.lib Still no success for now. Because it solves a bunch and gives a new bunch of unresolved symbols =(... If a can't compile at all, I will post the progess here.. Not that anybody is interested, but.. who knows. Edited May 3, 2022 by opc0d3
opc0d3 Posted May 7, 2022 Author Posted May 7, 2022 On 5/1/2022 at 4:28 PM, atom0s said: Microsoft made a translation layer lib for older CRT compiled libraries to be compatible with newer versions of VS. You can try and see if it helps in your situation. Add an import to the library: legacy_stdio_definitions.lib You can do this either via a direct #pragma call like: #pragma comment(lib, "legacy_stdio_definitions.lib") Or you can add it directly in the project settings under: Linker -> Input -> Additional Dependencies Just to update this topic. I was able to compile everything. Just used the default libs. Removed "NODEFAULTLIB" option from the project and I was adding only the necessary ones. vcruntime.lib, msvcrtd.lib, libcpmtd.lib This 3 solved my problems.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now