www.digitalmars.com         C & C++   DMDScript  

D - how to link D .obj files? - need help for comand line - passed on forum.exe

reply Felix <Felix_member pathlink.com> writes:
Writing a .bat file for automatic compilation (part of a GUI compiler wrapper),
I split the compilation in "compile only" and "link".
However, I need help on the following points:

1- the linker does not support long names for files
2- I cannot link the .obj files against phobos.lib unless I copy phobos.lib in
objdir (passing it as c:\dmd\lib\phobos.lib doesn't seem to work)
3- how could I specify the "library directories" to search?
4- is there any method to overwrite the sc.ini settings? (ev. via a "current
directory" sc.ini file?)
5- how exactly dmd.exe calls the linker since it succeeds to link the files?
(hidden parameters, environ. variables?)

Notice that while one coud directly link in one step (passing everything in
dmd.exe command line), the points 1,3 and 4 are not counturnable this way (by
example, setting env. variables has no effect since sc.ini files overwrite
them). More,  the "linkcmd" could be overwritten?

The philosophy behind this is to construct a batch file to compile and link a
project but allowing full parameter customization. I would like an example if
possible.

Attached should be a rar.sfx archive containing the sources (you need Borland
C++ Builder 6). However, right now I try to imagine how to implement the
following method:

void TfrmMain::constructBatchFile(void)// in file Unit1.cpp
{
AnsiString lineOfText;

batchContent=new TStringList;//we initialize the batch file content
lineOfText="";
//here we construct (and save) the batch file to build project
batchContent->Add(lineOfText.sprintf("\nREM This is a batch file created by
%s",ExtractFileName(Application->ExeName)));
batchContent->Add(lineOfText.sprintf("\nREM We set up..."));
//first we go to project's directory
batchContent->Add(lineOfText.sprintf("\n%s",ExtractFileDrive(frmProjectSettingsResult.ProjectFolder)));
batchContent->Add(lineOfText.sprintf("\ncd
%s",frmProjectSettingsResult.ProjectFolder));
//now we call the compiler...
//now we pass the source files to obtain the .obj files
frmProjectSettingsResult.ProjectFiles->QuoteChar='\"';//enclose names in quotes
frmProjectSettingsResult.ProjectFiles->Delimiter=' ';//separe them with spaces
lineOfText=lineOfText.sprintf("\n%s -c
%s",frmCompilerSettingsResult.CompilerPath,frmProjectSettingsResult.ProjectFiles->DelimitedText);
batchContent->Add(lineOfText); //here we should have the files compilled
//SAVING
//now we save the batch file in project's directory under name "AppName.bat"
batchName=frmProjectSettingsResult.ProjectFolder+"\\"+ChangeFileExt(ExtractFileName(Application->ExeName),".bat");
batchContent->SaveToFile(batchName);
};

Any idea will be welcomed. Thanks
Jan 08 2004
next sibling parent reply Mark Arts <Mark_member pathlink.com> writes:
Why would you want to compile and link seperately when it is done automtically
when you use dmd.exe? You could also write one batch file that uses commandline
arguments. For example:

C:\D\dmd\bin\dmd %1 %2
%2

Which automatically compiles and links (if you have dmc in the directory
C:\D\dm\bin) the file [second argument : %2] using options/switches [first
argument : %1], and runs the file. So when you call this batch file d.bat, you
could call it with for example:

d test.d

Does this help?

In article <btj6hf$1rgi$1 digitaldaemon.com>, Felix says...
Writing a .bat file for automatic compilation (part of a GUI compiler wrapper),
I split the compilation in "compile only" and "link".
However, I need help on the following points:

1- the linker does not support long names for files
2- I cannot link the .obj files against phobos.lib unless I copy phobos.lib in
objdir (passing it as c:\dmd\lib\phobos.lib doesn't seem to work)
3- how could I specify the "library directories" to search?
4- is there any method to overwrite the sc.ini settings? (ev. via a "current
directory" sc.ini file?)
5- how exactly dmd.exe calls the linker since it succeeds to link the files?
(hidden parameters, environ. variables?)

Notice that while one coud directly link in one step (passing everything in
dmd.exe command line), the points 1,3 and 4 are not counturnable this way (by
example, setting env. variables has no effect since sc.ini files overwrite
them). More,  the "linkcmd" could be overwritten?

The philosophy behind this is to construct a batch file to compile and link a
project but allowing full parameter customization. I would like an example if
possible.

Attached should be a rar.sfx archive containing the sources (you need Borland
C++ Builder 6). However, right now I try to imagine how to implement the
following method:

void TfrmMain::constructBatchFile(void)// in file Unit1.cpp
{
AnsiString lineOfText;

batchContent=new TStringList;//we initialize the batch file content
lineOfText="";
//here we construct (and save) the batch file to build project
batchContent->Add(lineOfText.sprintf("\nREM This is a batch file created by
%s",ExtractFileName(Application->ExeName)));
batchContent->Add(lineOfText.sprintf("\nREM We set up..."));
//first we go to project's directory
batchContent->Add(lineOfText.sprintf("\n%s",ExtractFileDrive(frmProjectSettingsResult.ProjectFolder)));
batchContent->Add(lineOfText.sprintf("\ncd
%s",frmProjectSettingsResult.ProjectFolder));
//now we call the compiler...
//now we pass the source files to obtain the .obj files
frmProjectSettingsResult.ProjectFiles->QuoteChar='\"';//enclose names in quotes
frmProjectSettingsResult.ProjectFiles->Delimiter=' ';//separe them with spaces
lineOfText=lineOfText.sprintf("\n%s -c
%s",frmCompilerSettingsResult.CompilerPath,frmProjectSettingsResult.ProjectFiles->DelimitedText);
batchContent->Add(lineOfText); //here we should have the files compilled
//SAVING
//now we save the batch file in project's directory under name "AppName.bat"
batchName=frmProjectSettingsResult.ProjectFolder+"\\"+ChangeFileExt(ExtractFileName(Application->ExeName),".bat");
batchContent->SaveToFile(batchName);
};

Any idea will be welcomed. Thanks

Jan 08 2004
next sibling parent Mark Arts <Mark_member pathlink.com> writes:
So when you call this batch file d.bat, you
could call it with for example:

d test.d

This of course has to be for example: d -unittest test.d I can't edit my previous message
Jan 08 2004
prev sibling parent reply Felix <Felix_member pathlink.com> writes:
Thanks, but, by example, how could someone specify additional directories to
search for libs, without editing each time the sc.ini file?


In article <btjo5k$2kr4$1 digitaldaemon.com>, Mark Arts says...
Why would you want to compile and link seperately when it is done automtically
when you use dmd.exe? You could also write one batch file that uses commandline
arguments. For example:

C:\D\dmd\bin\dmd %1 %2
%2

Which automatically compiles and links (if you have dmc in the directory
C:\D\dm\bin) the file [second argument : %2] using options/switches [first
argument : %1], and runs the file. So when you call this batch file d.bat, you
could call it with for example:

d test.d

Does this help?

In article <btj6hf$1rgi$1 digitaldaemon.com>, Felix says...
Writing a .bat file for automatic compilation (part of a GUI compiler wrapper),
I split the compilation in "compile only" and "link".
However, I need help on the following points:

1- the linker does not support long names for files
2- I cannot link the .obj files against phobos.lib unless I copy phobos.lib in
objdir (passing it as c:\dmd\lib\phobos.lib doesn't seem to work)
3- how could I specify the "library directories" to search?
4- is there any method to overwrite the sc.ini settings? (ev. via a "current
directory" sc.ini file?)
5- how exactly dmd.exe calls the linker since it succeeds to link the files?
(hidden parameters, environ. variables?)

Notice that while one coud directly link in one step (passing everything in
dmd.exe command line), the points 1,3 and 4 are not counturnable this way (by
example, setting env. variables has no effect since sc.ini files overwrite
them). More,  the "linkcmd" could be overwritten?

The philosophy behind this is to construct a batch file to compile and link a
project but allowing full parameter customization. I would like an example if
possible.

Attached should be a rar.sfx archive containing the sources (you need Borland
C++ Builder 6). However, right now I try to imagine how to implement the
following method:

void TfrmMain::constructBatchFile(void)// in file Unit1.cpp
{
AnsiString lineOfText;

batchContent=new TStringList;//we initialize the batch file content
lineOfText="";
//here we construct (and save) the batch file to build project
batchContent->Add(lineOfText.sprintf("\nREM This is a batch file created by
%s",ExtractFileName(Application->ExeName)));
batchContent->Add(lineOfText.sprintf("\nREM We set up..."));
//first we go to project's directory
batchContent->Add(lineOfText.sprintf("\n%s",ExtractFileDrive(frmProjectSettingsResult.ProjectFolder)));
batchContent->Add(lineOfText.sprintf("\ncd
%s",frmProjectSettingsResult.ProjectFolder));
//now we call the compiler...
//now we pass the source files to obtain the .obj files
frmProjectSettingsResult.ProjectFiles->QuoteChar='\"';//enclose names in quotes
frmProjectSettingsResult.ProjectFiles->Delimiter=' ';//separe them with spaces
lineOfText=lineOfText.sprintf("\n%s -c
%s",frmCompilerSettingsResult.CompilerPath,frmProjectSettingsResult.ProjectFiles->DelimitedText);
batchContent->Add(lineOfText); //here we should have the files compilled
//SAVING
//now we save the batch file in project's directory under name "AppName.bat"
batchName=frmProjectSettingsResult.ProjectFolder+"\\"+ChangeFileExt(ExtractFileName(Application->ExeName),".bat");
batchContent->SaveToFile(batchName);
};

Any idea will be welcomed. Thanks


Jan 08 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Felix wrote:
 Thanks, but, by example, how could someone specify additional directories to
 search for libs, without editing each time the sc.ini file?

(I haven't tried this but it should work.) You could try changing the LIB environment variable which OPTLINK defaultly scans before linking. SET LIB = C:\SOMEDIR DMD whatever.d somelib.lib (inspired by the /SCANLIB switch in http://www.digitalmars.com/ctg/ctgLinkSwitches.html) -- Justin http://jcc_7.tripod.com/d/
Jan 08 2004
parent reply Felix <Felix_member pathlink.com> writes:
Thanks for the hint.
I missed tha doc page.
LIB was however overwritten by sc.ini file.

In article <btlmv3$2ife$1 digitaldaemon.com>, J C Calvarese says...
Felix wrote:
 Thanks, but, by example, how could someone specify additional directories to
 search for libs, without editing each time the sc.ini file?

(I haven't tried this but it should work.) You could try changing the LIB environment variable which OPTLINK defaultly scans before linking. SET LIB = C:\SOMEDIR DMD whatever.d somelib.lib (inspired by the /SCANLIB switch in http://www.digitalmars.com/ctg/ctgLinkSwitches.html) -- Justin http://jcc_7.tripod.com/d/

Jan 09 2004
parent reply "Walter" <walter digitalmars.com> writes:
"Felix" <Felix_member pathlink.com> wrote in message
news:btlsmi$2s60$1 digitaldaemon.com...
 Thanks for the hint.
 I missed tha doc page.
 LIB was however overwritten by sc.ini file.

You can pass switches to the linker via the -L switch to dmd.
Jan 10 2004
parent Felix <Felix_member pathlink.com> writes:
Thanks, but I choose to rewrite (temporarlily the sc.ini files). It seems to
work...
If I remember the /SCANLIB was added to the LIB setting and I wanted to avoid
this.
Also, when I rose this question, I didn't knew about the linker's flags page, so
everithyng was dark. Now it is clearer, but I have no more time (till WE).
Congratulations for 0.78!



In article <btq0ds$d5c$1 digitaldaemon.com>, Walter says...
"Felix" <Felix_member pathlink.com> wrote in message
news:btlsmi$2s60$1 digitaldaemon.com...
 Thanks for the hint.
 I missed tha doc page.
 LIB was however overwritten by sc.ini file.

You can pass switches to the linker via the -L switch to dmd.

Jan 14 2004
prev sibling parent "Phill" <phill pacific.net.au> writes:
The compiler flags are listed   this URL:
http://www.digitalmars.com/d/dcompiler.html

and the sc.ini file is  
 \dmd\bin\sc.ini

Phill.


"Felix" <Felix_member pathlink.com> wrote in message
news:btj6hf$1rgi$1 digitaldaemon.com...
 Writing a .bat file for automatic compilation (part of a GUI compiler

 I split the compilation in "compile only" and "link".
 However, I need help on the following points:

 1- the linker does not support long names for files
 2- I cannot link the .obj files against phobos.lib unless I copy

 objdir (passing it as c:\dmd\lib\phobos.lib doesn't seem to work)
 3- how could I specify the "library directories" to search?
 4- is there any method to overwrite the sc.ini settings? (ev. via a

 directory" sc.ini file?)
 5- how exactly dmd.exe calls the linker since it succeeds to link the

 (hidden parameters, environ. variables?)

 Notice that while one coud directly link in one step (passing everything

 dmd.exe command line), the points 1,3 and 4 are not counturnable this way

 example, setting env. variables has no effect since sc.ini files overwrite
 them). More,  the "linkcmd" could be overwritten?

 The philosophy behind this is to construct a batch file to compile and

 project but allowing full parameter customization. I would like an example

 possible.

 Attached should be a rar.sfx archive containing the sources (you need

 C++ Builder 6). However, right now I try to imagine how to implement the
 following method:

 void TfrmMain::constructBatchFile(void)// in file Unit1.cpp
 {
 AnsiString lineOfText;

 batchContent=new TStringList;//we initialize the batch file content
 lineOfText="";
 //here we construct (and save) the batch file to build project
 batchContent->Add(lineOfText.sprintf("\nREM This is a batch file created

 %s",ExtractFileName(Application->ExeName)));
 batchContent->Add(lineOfText.sprintf("\nREM We set up..."));
 //first we go to project's directory

ngsResult.ProjectFolder)));
 batchContent->Add(lineOfText.sprintf("\ncd
 %s",frmProjectSettingsResult.ProjectFolder));
 //now we call the compiler...
 //now we pass the source files to obtain the .obj files
 frmProjectSettingsResult.ProjectFiles->QuoteChar='\"';//enclose names in

 frmProjectSettingsResult.ProjectFiles->Delimiter=' ';//separe them with

 lineOfText=lineOfText.sprintf("\n%s -c

iles->DelimitedText);
 batchContent->Add(lineOfText); //here we should have the files compilled
 //SAVING
 //now we save the batch file in project's directory under name


ileName(Application->ExeName),".bat");
 batchContent->SaveToFile(batchName);
 };

 Any idea will be welcomed. Thanks

Jan 08 2004