View previous topic :: View next topic |
Author |
Message |
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Sat Nov 18, 2006 8:36 am Post subject: Beginner question - version(build) not working?? |
|
|
Hello
I'm a beginner in both DMD and bud, and I'm having a basic problem: The version(build) is not working with me. But this is just one problem. Here is what I'm trying to do:
1- I created a library (obj.lib), having just 1 function:
Code: |
extern(Windows)
{
int Average(int a, int b)
{
return (a+b)/2;
}
}
|
I compiled it using bud, and the lib file is generated successfully.
2- Create a project (using Poseidon editor), in order to use this lib inside:
Code: |
import std.stdio;
extern(Windows) int Average(int a, int b);
version(build)
{
pragma(msg, "Build version used");
pragma(link, "obj.lib");
}
int main()
{
int x = 10;
int y = 20;
int z;
z = Average(x,y);
writefln("Average=?d",z);
return 0;
}
|
But the version(build) is ignored, so for example the msg "Build version used" is not displayed!
But what annoys me the most is that I do not receive any error message, saying that the Average function is not found for example. And I simply do not get an EXE generated. (just an obj file).
If I comment the line
The EXE file is generated.
I made a 2nd attempt, by adding "-version=build" to the switches, and here is what I get:
Quote: |
cwd > C:\D-Projects\tstobj
build.exe tstobj.d -full -O -LIBPATH=C:\D-Projects\obj -v -version=build
parse tstobj
semantic tstobj
Build pragma used
tstobj.d(8 ): pragma link unrecognized pragma(link)
Finished |
So the 2nd question is why isn't the link pragma recognized?
(Note: I renamed the tool as build.exe in order to be able to use it with Poseidon)
And this pops up a 3rd question: The -version switch is a DMD switch, not a bud switch (I didn't find it in bud's documentation), so why it functionned? Does bud accept all DMD switches?
Thanks in advance
John |
|
Back to top |
|
|
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Sat Nov 18, 2006 1:57 pm Post subject: Found a solution |
|
|
Hi Again
Another attempt: Use command line (I found a topic in Poseidon's sub-forum, mentioning a problem in displaying linker's output in the output window):
C:\D-Projects\tstobj>bud_win_3.04.exe tstobj.d -full -O -LIBPATH=c:\D-Projects\obj -v
parse tstobj
semantic tstobj
semantic2 tstobj
semantic3 tstobj
code tstobj
generating code for function 'main'
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
obj.lib
Warning 2: File Not Found obj.lib
tstobj.obj(tstobj)
Error 42: Symbol Undefined _Average@8
So the -LIBPATH switch is not working!
And here is how it works at last: specify the lib by its full path in the source file:
Code: |
version(build)
{
pragma(msg, "Build version used");
pragma(link,`C:\D-Projects\obj\obj.lib`); //backquotes are necessary to turn off special meaning of the backslash
//pragma(link, obj.lib);
}
|
and compile it as follows:
C:\D-Projects\tstobj>bud_win_3.04.exe tstobj.d -full -O -v
parse tstobj
semantic tstobj
semantic2 tstobj
semantic3 tstobj
code tstobj
generating code for function 'main'
after this, I succeeded to reach the same result using Poseidon.
So as a conclusion, the version(build) is indeed working, but the problem was with Poseidon in showing linker output.
But still there are 3 questions:
1- Why isn't the -LIBPATH working?
2- Why isn't the msg pragma working inside the version block?
3- I made a deliberate mistake, by mistyping the "link" pragma:
Code: |
version(build)
{
pragma(msg, "Build version used");
pragma(linksss, `C:\D-Projects\obj\obj.lib`);
}
|
But I got no error stating that this pragma is invalid. Is this a DMD issue or a bud issue? (If it is an issue at all )
Thanks
John |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Sat Nov 18, 2006 3:24 pm Post subject: Re: Found a solution |
|
|
John Kiro wrote: |
1- Why isn't the -LIBPATH working?
|
I don't know. It is working exactly like I think it should but I agree that it is not having the desired effect. What it does is add the paths named by you to the ones found in the sc.ini file and then present the lot to the system as an environment symbol. This is because the linker gets the library paths from the LIB environment symbol.
I'll do some more research.
John Kiro wrote: | 2- Why isn't the msg pragma working inside the version block?
|
Because 'msg' is not a Build pragma.
John Kiro wrote: | 3- I made a deliberate mistake, by mistyping the "link" pragma:
|
Build, for good or bad, just ignores pragmas that it doesn't recognise. I should really change this so it brings up an error message instead. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Sun Nov 19, 2006 2:50 pm Post subject: |
|
|
Thanks Derek
A 4th question, which i already asked in my 1st post, is about the -version switch: Why did it work with bud, although it is a DMD switch? Does bud pass the un-recognized switches to DMD?
John |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Sun Nov 19, 2006 4:19 pm Post subject: |
|
|
John Kiro wrote: | Thanks Derek
A 4th question, which i already asked in my 1st post, is about the -version switch: Why did it work with bud, although it is a DMD switch? Does bud pass the un-recognized switches to DMD?
|
Sorry, I missed that one.
Yes, any switch that Bud is not interested in is just passed through to DMD. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Wed Nov 22, 2006 1:18 pm Post subject: |
|
|
Thanks again
For 2nd point, I don't know if it's possible or not to enable the msg pragma inside the build block, but I see it would be useful. I guess it is a DMD issue not a build issue though.
For 4th point, I suggest to add it to the documentation
John |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Wed Nov 22, 2006 5:50 pm Post subject: |
|
|
John Kiro wrote: | Thanks again
For 2nd point, I don't know if it's possible or not to enable the msg pragma inside the build block, but I see it would be useful. I guess it is a DMD issue not a build issue though.
For 4th point, I suggest to add it to the documentation
John |
Excellent suggestions. Coming soon to a BUILD new you _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
|
|
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
|