www.digitalmars.com         C & C++   DMDScript  

c++ - library search path

reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
Hi,

I have a problem with extending the lib search path, ie:-
    -LC:\MyLibs
seems to make sc think that I'm specifying a linker that it can't find.

I'm very new to DM, so I'm assuming that this is a fundamental oversite on
my part.

--
Marc.
Sep 21 2002
parent reply Jan Knepper <jan smartsoft.cc> writes:
Marc Kealy wrote:

 I have a problem with extending the lib search path, ie:-
     -LC:\MyLibs
 seems to make sc think that I'm specifying a linker that it can't find.
Yes, that's what you do. When you start sc.exe or dmc.exe without paramters it will tell you what -L is for. Jan
Sep 21 2002
parent reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
In the docs for sc, it says that you can also use '-L' to pass arguments to
the linker and gives an example of passing both a switch and a lib search
path.

If this is not the prefered method, could anybody tell me what is?

Thanks

--
Marc.

"Jan Knepper" wrote
 Marc Kealy wrote:

 I have a problem with extending the lib search path, ie:-
     -LC:\MyLibs
 seems to make sc think that I'm specifying a linker that it can't find.
Yes, that's what you do. When you start sc.exe or dmc.exe without paramters it will tell you
what -L is
 for.

 Jan
Sep 21 2002
next sibling parent reply Jan Knepper <jan smartsoft.cc> writes:
That's -L/
with -L you specify the linker (most likely an external one)
with -L/ you specify arguments to the linker.



Marc Kealy wrote:

 In the docs for sc, it says that you can also use '-L' to pass arguments to
 the linker and gives an example of passing both a switch and a lib search
 path.

 If this is not the prefered method, could anybody tell me what is?

 Thanks

 --
 Marc.

 "Jan Knepper" wrote
 Marc Kealy wrote:

 I have a problem with extending the lib search path, ie:-
     -LC:\MyLibs
 seems to make sc think that I'm specifying a linker that it can't find.
Yes, that's what you do. When you start sc.exe or dmc.exe without paramters it will tell you
what -L is
 for.

 Jan
Sep 21 2002
parent reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
Jan,
I appreciate you taking the time to answer my questions, but please don't
assume that I'm an idiot.  Although I'm new to DM, I'm quite familiar with
the concepts of using compilers (Borland + GCC).

Now, in order to extend the lib search, I can find two options:
1. Use the 'LIB' environment variable.  This is a last resort for me.
2. Use -L???.  This is what the manual says:-

    -L/switch  Pass /switch to linker.
     For example, this command:
         sc test -L/packcode -L\test\prog
     adds the option /packcode and the library search path
     \test\prog to the linker's command line.

You'll notice that the second argument of this example dosn't use the '/'
charactor, but goes straight into a relative path.  Now, a relative path is
not what I want, I want to use an absolute path.

So, what I'd like to know is:-
    Is there a way to use the '-L' switch to add an absolute path to the lib
search?
    If not;  Are there other options than those above?
    How do you do it?

--
Marc.

"Jan Knepper"  wrote
 That's -L/
 with -L you specify the linker (most likely an external one)
 with -L/ you specify arguments to the linker.



 Marc Kealy wrote:

 In the docs for sc, it says that you can also use '-L' to pass arguments
to
 the linker and gives an example of passing both a switch and a lib
search
 path.

 If this is not the prefered method, could anybody tell me what is?

 Thanks

 --
 Marc.

 "Jan Knepper" wrote
 Marc Kealy wrote:

 I have a problem with extending the lib search path, ie:-
     -LC:\MyLibs
 seems to make sc think that I'm specifying a linker that it can't
find.
 Yes, that's what you do.
 When you start sc.exe or dmc.exe without paramters it will tell you
what -L is
 for.

 Jan
Sep 21 2002
parent reply Jan Knepper <jan smartsoft.cc> writes:
 1. Use the 'LIB' environment variable.  This is a last resort for me.
That would work.
 2. Use -L???.  This is what the manual says:-

     -L/switch  Pass /switch to linker.
      For example, this command:
          sc test -L/packcode -L\test\prog
      adds the option /packcode and the library search path
      \test\prog to the linker's command line.
What about -L/-Lc:\test\prog ??? Jan
Sep 21 2002
parent "Marc Kealy" <marc kealy.fslife.co.uk> writes:
"Jan Knepper" <jan smartsoft.cc> wrote in message
news:3D8CB83D.392328AC smartsoft.cc...
 1. Use the 'LIB' environment variable.  This is a last resort for me.
That would work.
 2. Use -L???.  This is what the manual says:-

     -L/switch  Pass /switch to linker.
      For example, this command:
          sc test -L/packcode -L\test\prog
      adds the option /packcode and the library search path
      \test\prog to the linker's command line.
What about -L/-Lc:\test\prog ??? Jan
No. I've tried a few different things like that. -- Marc.
Sep 21 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
The library search path is controlled by the LIB environment variable:

    www.digitalmars.com/ctg/optlink.html#environment


"Marc Kealy" <marc kealy.fslife.co.uk> wrote in message
news:ami76c$2ld0$1 digitaldaemon.com...
 In the docs for sc, it says that you can also use '-L' to pass arguments
to
 the linker and gives an example of passing both a switch and a lib search
 path.

 If this is not the prefered method, could anybody tell me what is?

 Thanks

 --
 Marc.

 "Jan Knepper" wrote
 Marc Kealy wrote:

 I have a problem with extending the lib search path, ie:-
     -LC:\MyLibs
 seems to make sc think that I'm specifying a linker that it can't
find.
 Yes, that's what you do.
 When you start sc.exe or dmc.exe without paramters it will tell you
what -L is
 for.

 Jan
Sep 21 2002
parent reply Mark Evans <Mark_member pathlink.com> writes:
Walter,

You should promote the use of sc.ini more often.  I like programs that are
self-contained and require no registry or environment settings.  Especially when
I also have MSVC6 on board, which does!

Sc.ini should be the preferred method IMHO.

Mark


The library search path is controlled by the LIB environment variable:

    www.digitalmars.com/ctg/optlink.html#environment
Sep 21 2002
next sibling parent "Walter" <walter digitalmars.com> writes:
Yes, you are right. I wish more programs were self-contained. I had to keep
after people to keep this working, the install programmers kept wanting to
muck with the system directory and registry settings <g>.

"Mark Evans" <Mark_member pathlink.com> wrote in message
news:amip9g$udg$1 digitaldaemon.com...
 Walter,

 You should promote the use of sc.ini more often.  I like programs that are
 self-contained and require no registry or environment settings.
Especially when
 I also have MSVC6 on board, which does!

 Sc.ini should be the preferred method IMHO.

 Mark


The library search path is controlled by the LIB environment variable:

    www.digitalmars.com/ctg/optlink.html#environment
Sep 21 2002
prev sibling parent reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
"Mark Evans"  wrote
 Walter,

 You should promote the use of sc.ini more often.  I like programs that are
 self-contained and require no registry or environment settings.
Especially when
 I also have MSVC6 on board, which does!

 Sc.ini should be the preferred method IMHO.

 Mark

The library search path is controlled by the LIB environment variable:

    www.digitalmars.com/ctg/optlink.html#environment
I was under the impression that the settings in the '.ini' file were just used to set the environment variables. And BTW, it seems that the default paths are still checked first, even when you set 'LIB' / 'INCLUDE'. Is there no way to over-ride these paths other than change their names? -- Marc.
Sep 21 2002
next sibling parent reply bw <bw_member pathlink.com> writes:
i have msvc too i've been working on batch files to help me use both from the
command line... these might help you, might not, but i usually set include= and
lib= when using digital mars it seems to run just fine without them.  might take
some editing if you want to use these, but it's just an example...

---
 echo off
rem this is cppvars.bat

if "%1"=="dm" goto dm
if "%1"=="ms" goto ms

if "%CPP%"=="" set CPP=none
echo Sets Environment for C++ Programming
echo Usage:   cppvars [MS or DM]
echo          MS=Microsoft
echo          DM=Digital Mars
echo current: %CPP%
if "%CPP%"=="none" set CPP=
goto end

:dm
if "%CPP%"=="MS" call msvcvars.bat
call dmcvars.bat
goto end

:ms
if "%CPP%"=="DM" call dmcvars.bat
call msvcvars.bat
goto end

:end
rem end cppvars.bat
---

 echo off
rem dmcvars.bat
if "%CPP%"=="DM" goto remove

subst s: c:\cpp\dm
set path=s:\bin;c:\windows;c:\windows\command;c:\xdos;
set INCLUDE=
set LIB=
set CPP=DM
echo DM++ variables set
goto end

:remove
c:
subst s: /d
set path=c:\windows;c:\windows\command;c:\xdos;
set CPP=
echo DM++ variables removed
goto end

:end
rem end dmcvars.bat

---
 echo off
rem msvcvars.bat
if "%CPP%"=="MS" goto remove

set TOOLROOTDIR=C:\MSVC
set PATH=C:\MSVC\BIN;c:\windows;c:\windows\command;c:\xdos;
set INCLUDE=C:\MSVC\INCLUDE;C:\MSVC\MFC\INCLUDE;
set LIB=C:\MSVC\LIB;C:\MSVC\MFC\LIB;
set CPP=MS
echo MSVC++ variables set
goto end

:remove
set CPP=
set TOOLROOTDIR=
set INCLUDE=
set LIB=
set PATH=c:\windows;c:\windows\command;c:\xdos;
echo MSVC++ variables removed

:end
rem end msvcvars.bat
---
Sep 21 2002
parent "Marc Kealy" <marc kealy.fslife.co.uk> writes:
"bw" wrote
 i have msvc too i've been working on batch files to help me use both from
the
 command line... these might help you, might not, but i usually set
include= and
 lib= when using digital mars it seems to run just fine without them.
might take
 some editing if you want to use these, but it's just an example...

 [snip code...]
Thanks bw, but as I'm running DM from within my own IDE, I can save the VC strings, set the DM strings, run a compile and then reset the VC strings: Which is no more hassle than writing the initial code to do so. No, the real problem is when you want to use DM and VC at the same time. If you start a compile with DM, you don't want to have to sit and wait for it to finish before you can use VC. You could waste an awful lot of hours in day like that. This example only uses these two compilers, but there are many other compilers out there and there are probably many more on the way. Who's to know what combinations of tools (and environment variables) people are going to be using. This is why it's far safer and more convenient (in a broader view) to bypass the environment variables and set paths, etc. explicitly. -- Marc.
Sep 21 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"Marc Kealy" <marc kealy.fslife.co.uk> wrote in message
news:amj0cn$1ig3$1 digitaldaemon.com...
 I was under the impression that the settings in the '.ini' file were just
 used to set the environment variables.
They do, but only for child processes. They do not change the global environment settings.
 And BTW, it seems that the default paths are still checked first, even
when
 you set 'LIB' / 'INCLUDE'.
What do you mean by the default paths?
Sep 21 2002
parent reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
"Walter" wrote
 "Marc Kealy" wrote
 I was under the impression that the settings in the '.ini' file were
just
 used to set the environment variables.
They do, but only for child processes. They do not change the global environment settings.
 And BTW, it seems that the default paths are still checked first, even
when
 you set 'LIB' / 'INCLUDE'.
What do you mean by the default paths?
If I wanted to substitute one of the windows headers, for example, I would need to replace it in the 'DM\Include\Win32\' dir instead of putting it in '\MyHeaders\' and telling sc to search 'MyHeaders' before 'DM\Include\Win32\'. -- Marc.
Sep 21 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Marc Kealy" <marc kealy.fslife.co.uk> wrote in message
news:amj75g$2809$1 digitaldaemon.com...
 If I wanted to substitute one of the windows headers, for example, I would
 need to replace it in the 'DM\Include\Win32\' dir instead of putting it in
 '\MyHeaders\' and telling sc to search 'MyHeaders' before
 'DM\Include\Win32\'.
Just go: -I\myheaders or in sc.ini: INCLUDE=\myheaders;\dm\include\win32
Sep 21 2002
parent reply "Marc Kealy" <marc kealy.fslife.co.uk> writes:
"Walter" wrote
 "Marc Kealy" <marc kealy.fslife.co.uk> wrote in message
 news:amj75g$2809$1 digitaldaemon.com...
 If I wanted to substitute one of the windows headers, for example, I
would
 need to replace it in the 'DM\Include\Win32\' dir instead of putting it
in
 '\MyHeaders\' and telling sc to search 'MyHeaders' before
 'DM\Include\Win32\'.
Just go: -I\myheaders or in sc.ini: INCLUDE=\myheaders;\dm\include\win32
Yes! A bit silly, that one. I just changed the '.ini' file from:- INCLUDE=...default-paths...;%INCLUDE% to:- INCLUDE=%INCLUDE%;...default-paths... and that's that one solved. It's 4:30 am here! That's my excuse. -- Marc.
Sep 21 2002
parent "Walter" <walter digitalmars.com> writes:
"Marc Kealy" <marc kealy.fslife.co.uk> wrote in message
news:amjcvr$30l9$1 digitaldaemon.com...
 and that's that one solved.
Glad it's working for you now. I wish all problems were so easilly resolved!
Sep 21 2002