Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I ask VC++ linker to ignore unresolved externals?

I'm trying to build a very complex open-source project with VC++. The project consists of dozens of libraries and one executable depending on those libraries.

For some reasons VC++ linker doesn't want to see about 40 functions implemented in one of those libraries and reports "unresolved external reference" on each, so I can't link. I don't want to waste time resolving the problem - those functions are likely never called.

I'd like to just ask the linker to link what it sees and insert some reasonable error handling (like reporting an error and terminating the program) instead of missing functions. How can I do that?

like image 585
sharptooth Avatar asked Feb 24 '10 13:02

sharptooth


2 Answers

You can use the /FORCE:UNRESOLVED linker option.

The documentation for that contains the rather understated warning:

A file created with this option may not run as expected.

In pratice, there'll be no error handling - just a crash.

like image 131
JoeG Avatar answered Nov 11 '22 03:11

JoeG


If the functions are truly never called, then create actual libraries (.lib files) for the libraries. Then the linker will only extract from the libraries what's needed.

The linker's job is to resolve all references, so I don't think you're going to get it to insert error handling code.

P.S. The first thing I'd check is to see if C functions got compiled as C++, leading to the missing symbols.

like image 6
user261840 Avatar answered Nov 11 '22 04:11

user261840