compiler and linker directives in Visual C++ 2005

  • Thread starter Thread starter fade
  • Start date Start date
F

fade

Good afternoon

Is there a way to tell the compiler and linker where to look for my
header files and libraries directly on the code?
(I'm not talking about changing
project properties, linker, additional lib dirs... )

I can tell what libs I want to use, with this:
eg.
#define MATLAB_LIB_1 "C:\\Program Files\\MATLAB71\\extern\\lib\\win32
\\microsoft\\msvc70\\libeng.lib"
#pragma comment(lib, MATLAB_LIB_1)

As you see I'm telling the full pathname for libeng.lib
How do I tell the linker where to look for libs?
And how do I tell the compiler where to look for headers?

TIA
 
fade said:
Good afternoon

Is there a way to tell the compiler and linker where to look for my
header files and libraries directly on the code?
(I'm not talking about changing
project properties, linker, additional lib dirs... )

I can tell what libs I want to use, with this:
eg.
#define MATLAB_LIB_1 "C:\\Program Files\\MATLAB71\\extern\\lib\\win32
\\microsoft\\msvc70\\libeng.lib"
#pragma comment(lib, MATLAB_LIB_1)

As you see I'm telling the full pathname for libeng.lib
How do I tell the linker where to look for libs?
And how do I tell the compiler where to look for headers?

You use the command line options and/or project settings.

Other than the use of #pragma comment that you've already discovered, there
are no other mechanisms that I'm aware of to pass absolute paths to the
linker/compiler from within the source code itself. That's a very unusual
thing to want to do that goes against most guidelines for sensible
development (imagine moving your code to another machine), so I don't expect
you're going to find exactly what you're looking for.

-cd
 
fade said:
Good afternoon

Is there a way to tell the compiler and linker where to look for my
header files and libraries directly on the code?
(I'm not talking about changing
project properties, linker, additional lib dirs... )

I can tell what libs I want to use, with this:
eg.
#define MATLAB_LIB_1 "C:\\Program Files\\MATLAB71\\extern\\lib\\win32
\\microsoft\\msvc70\\libeng.lib"
#pragma comment(lib, MATLAB_LIB_1)

As you see I'm telling the full pathname for libeng.lib
How do I tell the linker where to look for libs?
Doesn't your method do that?

Remember you can use automatic concatenation of string literals to merge
paths with filenames.

And how do I tell the compiler where to look for headers?
#include accepts a relative or absolute path, as well as a bare filename.
 
Back
Top