Subject Solved problem linking to ib_util.lib in MSVC 2008: _ib_util_malloc@4 unresolved
Author dancooperstock
I just solved my own problem, and wanted to help anyone else with the same problem!

I'm trying to write a UDF that returns memory allocated with ib_util_malloc, that can be freed with the FREE_IT directive.

I #included ib_util.h (after ibase.h), and added ib_util_ms.lib as an additional dependency in the Linker Input configuration screen.

However, while the code compiles, I got the error "unresolved external symbol _ib_util_malloc@4" from the linker.

If I do "dumpbin /exports ib_util_ms.lib", it shows a symbol _ib_util_malloc, without the @4. Clearly there's a mismatch.

It turns out that the problem is that I was compiling with the __stdcall calling convention, but ib_util_ms.lib was compiled with __cdecl. So to make it link, I removed #include <ib_util.h> and replaced it with:

extern void * __cdecl ib_util_malloc(long);

Everything is fine after that. Hope this might be helpful to anyone else with a similar problem.