473,406 Members | 2,698 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,406 software developers and data experts.

Conditionally link a library

Hello,

I use a #define like WITH_MYSTUFF to conditionally compile code within
#ifdef WITH_MYSTUFF. I would now like the same define to conditionally link
with a library. In the linker settings of VS.NET 2003 I have 'Input ->
Additional
Dependencies' where I can add my .lib files the linker should use.

How do I tell the linker (by a macro ?) somthing like this:

'link with mystuff.lib if WITH_MYSTUFF is defined'

Any idea how this could be done?

Many thanks, Felix
Nov 1 '06 #1
2 1288
Felix wrote:
Hello,

I use a #define like WITH_MYSTUFF to conditionally compile code within
#ifdef WITH_MYSTUFF. I would now like the same define to
conditionally link with a library. In the linker settings of VS.NET
2003 I have 'Input -Additional
Dependencies' where I can add my .lib files the linker should use.

How do I tell the linker (by a macro ?) somthing like this:

'link with mystuff.lib if WITH_MYSTUFF is defined'

Any idea how this could be done?
Simple answer: you can't.

More complicated answer: Generally, it's not necessary. If nothing in the
library is referenced (and presumably it's not, otherwise you'd be getting
unresolved external errors from the linker), then the linker won't pull
anything from the library into the linked image. It will make the link take
a little longer (a couple seconds at most, unless the library is extremely
large). You can try adding the /verbose option to your linker command line
options to see what happens to a library that's not referenced.

Most complicated answer: you can use another project system, such as a
hand-written makefile, to do your builds. In such an environment you could
decide which libraries to include in the link based on whatever criteria you
choose.

-cd
Nov 1 '06 #2

"Felix" <fb@ltec.chwrote in message
news:eh**************@TK2MSFTNGP04.phx.gbl...
Hello,

I use a #define like WITH_MYSTUFF to conditionally compile code within
#ifdef WITH_MYSTUFF. I would now like the same define to conditionally
link
with a library. In the linker settings of VS.NET 2003 I have 'Input ->
Additional
Dependencies' where I can add my .lib files the linker should use.

How do I tell the linker (by a macro ?) somthing like this:

'link with mystuff.lib if WITH_MYSTUFF is defined'
#if WITH_MYSTUFF
#pragma comment(lib, "mystuff")
#endif
>
Any idea how this could be done?

Many thanks, Felix


Nov 1 '06 #3

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

Similar topics

1
by: Thomas Matthews | last post by:
Hi, My goal is to extract a text field into a string type. The text field is from a buffer (array) of characters and delimited by white space or double quotes. *** I'm looking to perform this...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
2
by: Paul | last post by:
Just wondering if anyone knows how to conditionally load a user control on a page? In other words load the user control if the page is reached with one link and do not load it if it is reached by...
3
by: | last post by:
One thing I did a lot of in Classic ASP involved showing page elements conditionally based on whether a user was logged in or not. Logged in users or "superusers" would get more content and/or more...
5
by: Imran Aziz | last post by:
Hello all, I am populating the contents of a repeater control using a database query. In the repeater control I have a link , which I want to display or not based on the current logged in user....
2
by: Jens Weiermann | last post by:
Hi, I need to conditionally disable a html (not web forms) button control. The condition is to be evaluated server-side. What is the smartest way to do this? I'm now using a literal server-side...
15
by: d4 | last post by:
I have a vbscript (below) I want to rewrite in C# but I cannot get it to work (unless there is a better way to do it). The script will combine 2 lines if the (next) line contains a "+",...
1
by: burtonfigg | last post by:
I have a very simple bit of ajax with next / prev links on it (thanks to acoder who helped a lot with getting it to work): http://jimpix.co.uk/e.asp If I am at the start of the range, is there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.