sharptooth
sharptooth

Reputation: 170499

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?

Upvotes: 14

Views: 5602

Answers (4)

T.E.D.
T.E.D.

Reputation: 44804

There are some notable exceptions, but most OpenSource projects are not designed to be built under VisualStudio.

Generally for a Windows port you are better off using either cygwin or the mingw system. My advice is usually for mingw, unless the program uses a lot of Unix OSey calls like pipes and signals.

Upvotes: 1

DeadMG
DeadMG

Reputation: 111

If they're never called, remove the references from your project. If they are called, then fix the damn problem. There's no real other option here.

Upvotes: 5

JoeG
JoeG

Reputation: 13182

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.

Upvotes: 19

user261840
user261840

Reputation: 178

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.

Upvotes: 6

Related Questions