FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to build a library with object files relocated?

 
Post new topic   Reply to topic     Forum Index -> Build
View previous topic :: View next topic  
Author Message
Bradley Smith



Joined: 20 Jun 2006
Posts: 60

PostPosted: Thu Nov 09, 2006 3:14 pm    Post subject: How to build a library with object files relocated? Reply with quote

Given the files:
Code:
  file1.d
  file2.d
  project\all.d


Using the command
Code:
bud -lib -Tmylib.lib project\all.d

creates mylib.lib with object files created alongside source files.

However, using the command
Code:
bud -lib -Tmylib.lib project\all.d -odobjects

creates object files, mylib.def, mylib.rsp in the "objects" directory, but mylib.lib is not created.

Am I doing something wrong?
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Thu Nov 09, 2006 6:10 pm    Post subject: Re: How to build a library with object files relocated? Reply with quote

Bradley Smith wrote:
Given the files:
Code:
  file1.d
  file2.d
  project\all.d


Using the command
Code:
bud -lib -Tmylib.lib project\all.d

creates mylib.lib with object files created alongside source files.

However, using the command
Code:
bud -lib -Tmylib.lib project\all.d -odobjects

creates object files, mylib.def, mylib.rsp in the "objects" directory, but mylib.lib is not created.

Am I doing something wrong?


Try again with adding the switch "-allobj".

Without this, only the object files created in the same directory as the library file will be included. With this switch, all object files created in the same session are included.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Bradley Smith



Joined: 20 Jun 2006
Posts: 60

PostPosted: Thu Nov 09, 2006 6:52 pm    Post subject: Reply with quote

Great. Adding -allobj works.

I have a follow-on question. I noticed that all objects are created directly within the objects directory when using -odobjects. How do I get it to use the source file path?

I've tried the -op option. For example,

Given the files:
Code:
file1.d
file2.d
project\all.d
packageA\file1.d


Using the command
Code:
bud -lib -Tmylib.lib project\all.d -allobj -op -odobjects


My objects directory contains
Code:
all.obj
file1.obj
file2.obj
mylib.def
mylib.lsp
mylib.rsp


The object file for second file1.d source file has overritten the first. The -op option is not taking effect, as can be shown by the contents of the mylib.rsp file
Code:
-odobjects
-ID:\test\objects\
-Ic:\dmd\src\phobos\
-ID:\test\project\
-ID:\test\
-ID:\test\packageA\
-c
project\all.d
file1.d
file2.d
packageA\file1.d
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Thu Nov 09, 2006 10:17 pm    Post subject: Reply with quote

Bradley Smith wrote:
Great. Adding -allobj works.

I have a follow-on question. I noticed that all objects are created directly within the objects directory when using -odobjects. How do I get it to use the source file path?

I've tried the -op option.


The -od and -op switches are not meant to be used together.

-od<path> says write the object files to <path>
-op says write the object files to their source file location.

You can't do both.

If you want to just write them to their source path just use -op.

If you use neither, the object files are written to the current directory.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Bradley Smith



Joined: 20 Jun 2006
Posts: 60

PostPosted: Thu Nov 09, 2006 10:56 pm    Post subject: Reply with quote

Derek Parnell wrote:
The -od and -op switches are not meant to be used together.

-od<path> says write the object files to <path>
-op says write the object files to their source file location.

You can't do both.

That's odd. They appear to work perfectly together.
Code:
dmd -c -op -odobjects file1.d file2.d packageA\file1.d
lib -c mylib.lib objects\file1.obj objects\file2.obj objects\packageA\file1.obj


What -op actually says is this.

dmd --help wrote:
-op do not strip paths from source file

Which means that "packageA\file1.d" creates "packageA\file1.obj" in the object output directory.

Personally, I think object file paths should be taken from the fully qualified module names. Hopefully, my DMD enhancement request for this feature will be considered.
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Fri Nov 10, 2006 12:04 am    Post subject: Reply with quote

Bradley Smith wrote:
Derek Parnell wrote:
The -od and -op switches are not meant to be used together.

-od<path> says write the object files to <path>
-op says write the object files to their source file location.

You can't do both.

That's odd. They appear to work perfectly together.
Code:
dmd -c -op -odobjects file1.d file2.d packageA\file1.d
lib -c mylib.lib objects\file1.obj objects\file2.obj objects\packageA\file1.obj



Now try it again with absolute paths rather than relative paths. Then try using different drives as well. DMD soon starts getting weird.

Bradley Smith wrote:

What -op actually says is this.

dmd --help wrote:
-op do not strip paths from source file

Which means that "packageA\file1.d" creates "packageA\file1.obj" in the object output directory.


Yes, but it only applies to relative paths.

Bradley Smith wrote:

Personally, I think object file paths should be taken from the fully qualified module names. Hopefully, my DMD enhancement request for this feature will be considered.


I've been thinking that if -odD:\somewhere is used with -op and C:\here\mod.d is supplied on the commandline I should write the object file to

D:\somewhere\_c_\here\mod.obj

and pass this absolute name to the linker.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Build All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group