I'm currently trying to integrate a C code written for UNIX in C++ Builder. But a part of the code is using the function symlink :
if(!fname
|| (use_real_copy ? real_copy(path, fname) : symlink(path, fname))
I don't know how to replace it so it works in C++ Builder for Windows 64 bits, I've found the functions CreateSymbolicLinkW and CreateSymbolicLinkA that seem to be the equivalent for Windows but C++ Builder can't find them.
Do you have any idea of how I can get around this problem?
Thank you.
CreateSymbolicLink()is declared inwinbase.h, which is#include'd bywindows.h, which is#include'd byvcl.hin all VCL-based projects. If you are not creating a VCL project, make sure you have an#include <windows.h>statement in your code. Either way, also make sure that_WIN32_WINNTis defined to be at least0x0600(Vista+).If the compiler still complains that
CreateSymbolicLink()is undefined then you must be using an old version of C++Builder (CreateSymbolicLink()was added to C++Builder's copy ofwinbase.hin C++Builder 2007), in which case you will have to declareCreateSymbolicLink()manually in your own code, eg:But then you have another problem to tackle - that version of C++Builder would also not have the
CreateSymbolicLinkAandCreateSymbolicLinkWsymbols in its copy ofkernel32.libfor linking to the exported functions inkernel32.dll. So you would have to create a new.libimport library from a modernkernel32.dllthat includes those symbols, and then add it to your project. At which point, it would probably be easier to just dynamically loadCreateSymbolicLink()at runtime usingGetProcAddress()instead:Which will also allow your code to run on XP and earlier (if needed), since
CreateSymbolicLink()was added in Vista.