473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

MSVC not linking in "unused" libraries

At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.

Is there a link option to turn of this feature?

MSVC 7.1 .net 2003 69462-270-0000007-18536

Thanks,

Chris
Apr 3 '06 #1
6 2539
> At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.


You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 3 '06 #2

"Chris Stankevitz" wrote
At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.

Is there a link option to turn of this feature?


I'm going to try /OPT:NOREF
Apr 3 '06 #3

"Bruno van Dooren"
You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

Hi Bruno,

Thanks for the help. Do I have to use /INCLUDE for every symbol? My
developers are adding objects (symbols) via the Factory pattern every day.
I don't want to change my link options everytime I add an object. My app is
about 1 million lines of code.

I will try the /OPT:NOREF option.

Thanks,

Chris
Apr 3 '06 #4
> "Bruno van Dooren"
You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

Hi Bruno,

Thanks for the help. Do I have to use /INCLUDE for every symbol? My
developers are adding objects (symbols) via the Factory pattern every day.
I don't want to change my link options everytime I add an object. My app is
about 1 million lines of code.

I will try the /OPT:NOREF option.


If your libraries are dlls, then you have to reference only 1 symbol per
library.

If your libraries are static libraries, then a common technique is to have 1
function that is never to be called by actual code, put a call to all other
functions in there, and then use /INCLUDE to reference that unused function
that automatically references all other functions.

/OPT:NOREF is the default for debug builds, so if your debug configuration
does not include all the libraries, you know it won't work.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 4 '06 #5

"Bruno van Dooren" <br**********************@hotmail.com> wrote
If your libraries are static libraries, then a common technique is to have
1
function that is never to be called by actual code, put a call to all
other
functions in there, and then use /INCLUDE to reference that unused
function
that automatically references all other functions.


Bruno,

Thanks for your help.

I'm curious about this trick. What do you mean by "put a call to all other
functions"? Are you assuming that my static library consists of only global
functions? My static libraries consist of many classes each with many
functions, a few static functions, and some static variables. What would my
"dummy function" look like for such a static library?

Thanks,

Chris
Apr 11 '06 #6
> "Bruno van Dooren" <br**********************@hotmail.com> wrote
If your libraries are static libraries, then a common technique is to have
1
function that is never to be called by actual code, put a call to all
other
functions in there, and then use /INCLUDE to reference that unused
function
that automatically references all other functions.


Bruno,

Thanks for your help.

I'm curious about this trick. What do you mean by "put a call to all other
functions"? Are you assuming that my static library consists of only global
functions? My static libraries consist of many classes each with many
functions, a few static functions, and some static variables. What would my
"dummy function" look like for such a static library?


The way I saw this technique used after some googling (though i cannot find
that page again it seems. I hate it when that happens) looked like this:

void dummyFunctionForSymbolReference(void)
{
Class1 myClass1();
Class2 myClass3();
Class3 myClass3();
}

You only need to reference each class once inside the function that you
include by force. all the classes that are contained inside that function
should be added to the library.

You can easily test this with one of your classes that contain both member
and static function sand variables.

This page:
http://austria.sourceforge.net/dox/h...Factories.html
seems to describe another trick for making sure that symbols get included.
Maybe that could be usefull to you as well?

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"

Apr 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J. Campbell | last post by:
From reading this forum, it is my understanding that C++ doesn't require the compiler to keep code that does not manifest itself in any way to the user. For example, in the following: { for(int...
4
by: mairhtin o'feannag | last post by:
Hello, I have a tablespace striped across three drives, call them 1,2,3, just to be clever. :) I allocated a lot more space (DMS) than I should have, since I didn't know a way to estimate the...
0
by: Steve B. | last post by:
Hello I'm building a Web service that have some methods. I've also two datasets class : DataSet1 and DataSet2. If I add a method in my WS that waits for or return either DataSet1 and...
11
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via...
13
by: Rex Mottram | last post by:
I'm using an API which does a lot of callbacks. In classic callback style, each routine provides a void * pointer to carry user-defined data. Sometimes, however, the user-defined pointer is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.