views:

237

answers:

4

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?

+6  A: 

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.

+1 for the PS. .c files get name-mangled differently from .cpp files w/ VisualStudio. Depending on your settings, they might use a different calling convention too.
T.E.D.
Well, the are called sometimes, but when I use the program those paths are never exercised. So the linker is right - it needs the function. Still I want it to produce the executable. +1 anyway.
sharptooth
+7  A: 

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.

Joe Gauterin
+4  A: 

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.

DeadMG
+1  A: 

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.

T.E.D.