You must recompile the library. Setting #if or #ifdef effectively hide code from the compiler based on those directives or defines. You cannot change the compiled code after compiling it, so it must be recompiled.
unresolved external symbol in linked library, srand48 and drand48
题
I am working on compiling a code using Visual Studio that was previously compiled using vs10sp1 in cygwin. I am nearly finished, but I am getting 3 unresolved external symbol errors.
something like this:
libmetis.lib(util.obj) : error LNK2019: unresolved external symbol srand48 referenced in function __InitRandom
I have gathered that these symbols are in unix libraries, and are usually handled using compiler flags. And indeed upon review the source code has the flags,
if (seed == -1) {
#ifndef __VC__
srand48(7654321L);
#endif
srand(4321);
I am using a precompiled library, and I assume it was not build with these flags. (I am compiling without cygwin). Can I link with this flag to use the functionality that I require or do I need to recompile the library?
解决方案
不隶属于 StackOverflow