Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Search path working differently in XE5 from D2007...



Permlink Replies: 8 - Last Post: Dec 21, 2014 6:00 AM Last Post By: Carl-Henrik Nil...
Bo Berglund

Posts: 757
Registered: 10/23/02
Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 18, 2014 4:16 AM
I now have a new problem when I am converting the code in my D2007
test project to XE5: Path specifications seem to work oddly...

What happens is this:
1) I converted my component package such that it was possible to build
and install into XE5. All of the component sources are kept in a
different top folder for XE5 compared to D2007. This folder path is
set into an environment variable CMPXE5.
When converting the component package I also added the paths to my
global XE5 browsing path using the syntax $(CMPXE5)\SubfolderName and
it looked fine, XE5 could see that it was a valid path in all cases.

2) Now when I try to syntax check the old project I opened in XE5 I
get errors due to it not finding the source for a component, which was
installed just a few minutes back!

For example FormMain has in its interface section a list of uses units
where for example the component FormLangManager is flagged as not
found.
In desperation I have looked for all places paths are listed and
entered the corresponding path there, so now it is everywhere in the
XE5 global list (library and browsing) as well as in the project
settings where the "inherit" thing really muddens the overview.
Finally, when I had plugged it into every single place it looks like
it is found by XE5.

This is ridiculous!
Where should I place a component path and get it working?
Bo Berglund

Posts: 757
Registered: 10/23/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 18, 2014 8:02 AM   in response to: Bo Berglund in response to: Bo Berglund
On Thu, 18 Dec 2014 04:16:16 -0800, Bo Berglund
<bo dot berglund at nospam dot com> wrote:

I ran into another of these strange cases of the compiler not finding
units...
This time I added the path to the global Library path and this made it
work.

Question:
'When one works on a project and needs the compiler to reach some code
in say components, where is the proper place to enter the path?

It seems to be inappropriate to do so in the global options (library
path) but this is the only place I have found that makes it work.
Should there not be somewhere in the projecxt properties to do it
instead?
Carl-Henrik Nil...

Posts: 53
Registered: 3/26/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 18, 2014 1:04 PM   in response to: Bo Berglund in response to: Bo Berglund
Bo Berglund wrote:
I ran into another of these strange cases of the compiler not finding
units...
This time I added the path to the global Library path and this made it
work.

Question:
'When one works on a project and needs the compiler to reach some code
in say components, where is the proper place to enter the path?

It seems to be inappropriate to do so in the global options (library
path) but this is the only place I have found that makes it work.
Should there not be somewhere in the projecxt properties to do it
instead?

The global Library path is more for .bpl and .dcp files.

You can add the paths of the component source files (like .pas files) to the project:
Project|Options - Delphi Compiler - Search paths.
Now the compiler, debugger, and editor can see them.

But when you compile the project the components will then also be compiled and
their .dcu files will end up in the unit output folder specified for the project.

If you instead want to use the .dcu files that (most likely) are already compiled in the
component package project when you installed them, you don't add the paths of the component
source files (.pas files) to Search paths. Instead you add the .dcu files to it.
But now you have to add the source files (.pas files) to:
Tools|Options - Delphi Optins - Library - Browsing path.

Now the editor can see the source files but not the compiler, which will use the already
compiled units instead.
(This was explained to me by Andreas Hausladen).

It's a bit complicated, and you always have to pay attention to which target is selected in
the top combobox when you modify any setting. If you're intereted in more fun stuff you should
try using Option sets.
--
C-H
Bo Berglund

Posts: 757
Registered: 10/23/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 18, 2014 2:24 PM   in response to: Carl-Henrik Nil... in response to: Carl-Henrik Nil...
On Thu, 18 Dec 2014 13:04:43 -0800, Carl-Henrik Nilsson <> wrote:

Now the editor can see the source files but not the compiler, which will use the already
compiled units instead.
(This was explained to me by Andreas Hausladen).

It's a bit complicated, and you always have to pay attention to which target is selected in
the top combobox when you modify any setting. If you're intereted in more fun stuff you should
try using Option sets.

Thanks for the info!
What I really think would be the right thing (since my problems came
from the component suite I installed) is if I could somehow leave out
these sources altogether including the DCU files?
After all the package file should be all that is required for
compilation of the code, right?

So I have built and installed a custom package where all these
components have been included. What exactly should I do in order not
to have to add any of the source dirs into any path at all?
I really do not know where the package actually was deposited
either...

Well, I looked at the Components/Install packages menu and found that
my newly built package is deposited a long ways away from the sources,
very strange to me:

C:\Users\Public\Documents\RAD Studio\12.0\Bpl\CustomCmpXE5.bpl

What a drag! I never ever keep my development files on the C: drive!
They belong in the D: (data) drive in the proper path set aside for
XE5.
So how can I change this? What I want is to have the build/install of
the package send the files to my XE5 support folder tree on D:.
Do I have to uninstall the package altogether, then rebuild it while
setting some configurations such that it is deposited in the correct
place?
Or can I simply move the bpl file from that C: location?
Carl-Henrik Nil...

Posts: 53
Registered: 3/26/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 19, 2014 5:15 AM   in response to: Bo Berglund in response to: Bo Berglund
Bo Berglund wrote:
What I really think would be the right thing (since my problems came
from the component suite I installed) is if I could somehow leave out
these sources altogether including the DCU files?
After all the package file should be all that is required for
compilation of the code, right?

No, you need either the .dcu or the .pas files, and you really want both.
You have to mess with it. Delphi is evolving, and it's getting more and more powerful
and complex with every new release. It brings with it more setup work to do.
Cheating doesn't pay off in the long run.

So I have built and installed a custom package where all these
components have been included. What exactly should I do in order not
to have to add any of the source dirs into any path at all?
I really do not know where the package actually was deposited
either...

Well, I looked at the Components/Install packages menu and found that
my newly built package is deposited a long ways away from the sources,
very strange to me:

C:\Users\Public\Documents\RAD Studio\12.0\Bpl\CustomCmpXE5.bpl

That's in the default location of the Lib folder (BDSLIB).

What a drag! I never ever keep my development files on the C: drive!
They belong in the D: (data) drive in the proper path set aside for
XE5.
So how can I change this? What I want is to have the build/install of
the package send the files to my XE5 support folder tree on D:.
Do I have to uninstall the package altogether, then rebuild it while
setting some configurations such that it is deposited in the correct
place?
Or can I simply move the bpl file from that C: location?

No you can't.
You can of course go to Tools|Options and override the environment variable,
but I've never done that.

The other option is to change the path for the package project .bpl in the Project manager.
You can keep '.\$(Platform)\$(Config)' in Project|Options - Delphi Compiler - Unit output directory.
Add the new path to the Library path.

It's a good idea to uninstall the package first and delete the old output files to avoid confusion.
The paths in other projects referencing the components need to be reviewed afterwords of course.

Some guide lines:

Always separate Design time packages from Run time packages.
Always keep source files and output files in separate folders,
and always keep resource files and source files in separate folders.

Output files are placed in separate folders by default depending on
Target and Build configuration. That's what '.\$(Platform)\$(Config)' means.

You'll probably run into lots of problems, so you have a great learning experience to look forward to <g>.
Stay cool!
--
C-H
Bo Berglund

Posts: 757
Registered: 10/23/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 20, 2014 1:35 AM   in response to: Carl-Henrik Nil... in response to: Carl-Henrik Nil...
On Fri, 19 Dec 2014 05:15:59 -0800, Carl-Henrik Nilsson <> wrote:

Some guide lines:

Always separate Design time packages from Run time packages.
Always keep source files and output files in separate folders,
and always keep resource files and source files in separate folders.

Output files are placed in separate folders by default depending on
Target and Build configuration. That's what '.\$(Platform)\$(Config)' means.

You'll probably run into lots of problems, so you have a great learning experience to look forward to <g>.
Stay cool!

Well,
I have "always" located my project DCU files in a separate
subdirectory to the sources dir.
Yesterday I had a look there and to my astonishment I found that the
DCU dir contained not only the project source's dcu files but also the
component dcu's...
It seems like XE5 recompiles the components every time I compile/build
the project during development and places them into the dcu subdir for
the project.
Seems a counterintuitive procedure since the components are all
compiled when they were installed and nothing has changed in their
sources since then, so why does XE5 recompile them?

I went on the lookout for the package DCU's and found some here:
<package source dir>/Win32/Debug
This was presumably created during my install of the component
package. But there was no Release subdir...

Are the DCU's for components different for debugging and release?
If so, must I also build the release version of the package to create
these component dcu's? If I do so I see the Release subdir being
created with a bunch of dcu's.
Is this the dcu directory I should add to the project search path for
any of my projects?

As a test I did so but when I built the project (release) the
component DCU files were again created and put into this directory....
Is this what should be done?
Carl-Henrik Nil...

Posts: 53
Registered: 3/26/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 20, 2014 6:13 AM   in response to: Bo Berglund in response to: Bo Berglund
Bo Berglund wrote:
I have "always" located my project DCU files in a separate
subdirectory to the sources dir.
Yesterday I had a look there and to my astonishment I found that the
DCU dir contained not only the project source's dcu files but also the
component dcu's...
It seems like XE5 recompiles the components every time I compile/build
the project during development and places them into the dcu subdir for
the project.

As I tried to explain in the reply I posted on Dec 18 in this thread.

Seems a counterintuitive procedure since the components are all
compiled when they were installed and nothing has changed in their
sources since then, so why does XE5 recompile them?

It's now as designed and I don't have the exact answer to that.
But I imagine it's not a bad thing.

I went on the lookout for the package DCU's and found some here:
<package source dir>/Win32/Debug
This was presumably created during my install of the component
package. But there was no Release subdir...

So you probably never built the release configuration for the package.

Are the DCU's for components different for debugging and release?

Yes.

If so, must I also build the release version of the package to create
these component dcu's?

Yes.

If I do so I see the Release subdir being
created with a bunch of dcu's.
Is this the dcu directory I should add to the project search path for
any of my projects?

Yes.

As a test I did so but when I built the project (release) the
component DCU files were again created and put into this directory....
Is this what should be done?

They shouldn't end up in the Release folder of the application project,
if that's what you're asking?

You need to review the paths you have:
- The Search paths in the application Project options for Release 32 and Debug 32 respectively.
They should point to the unit output folders for Release 32 and Debug 32 in the package Project
(where the .dcus are).

- The unit output folders for Release 32 and Debug 32 in the package Project
(where the .dcus should be). They should both read: .\$(Platform)\$(Config)

- The Library paths you have in Tools|Options. Remove any folder that points to
a source folder or a .dcu output folder.

- The browsing paths in Tools| Options. They should point to the package Project
folders for the source files.

--
C-H
Bo Berglund

Posts: 757
Registered: 10/23/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 21, 2014 2:10 AM   in response to: Carl-Henrik Nil... in response to: Carl-Henrik Nil...
On Sat, 20 Dec 2014 06:13:10 -0800, Carl-Henrik Nilsson <> wrote:


As I tried to explain in the reply I posted on Dec 18 in this thread.

And I have done so and removed the specific entries pointing to the
source folders. I now have it set such that the global library path
points to the Win32/Release and Win32/Debug folders. I rebuilt the
package in both release and debug mode.
There is no mention of the package location in the project settings
anymore, but there are a couple of entries for things not included in
the component package.

Now I don't anymore get component dcu files into the dcu folder in the
project.

So that is solved for the main project.

But I have another related problem now:
The project group contains two exe targets, one is the full version
and one is a demo version where certain features have been taken out
by conditional compilation directives. Both projects use exactly the
same sources but they have different dcu output folders.

Now the demo version no longer compiles. It complains like this:
[dcc32 Error] E1026 File not found: 'FolderDialog.DCR'

I have no idea why a dcr file is required for the demo project, all
these project settings we discussed have been set the same as for the
full version and the FolderDialog component is in the component
package, which works fine for the full version.
It seems so illogical that the DCR file is needed, it is located in
the FolderDialog source dir, but it does help if I add that to the
project search path, but why should I have to do that for this single
folder and only for the demo project? Makes no sense....
Carl-Henrik Nil...

Posts: 53
Registered: 3/26/02
Re: Search path working differently in XE5 from D2007...
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 21, 2014 6:00 AM   in response to: Bo Berglund in response to: Bo Berglund
Bo Berglund wrote:
So that is solved for the main project.

Making progress. :-)

But I have another related problem now:
The project group contains two exe targets, one is the full version
and one is a demo version where certain features have been taken out
by conditional compilation directives. Both projects use exactly the
same sources but they have different dcu output folders.

Now the demo version no longer compiles. It complains like this:
[dcc32 Error] E1026 File not found: 'FolderDialog.DCR'

I have no idea why a dcr file is required for the demo project, all
these project settings we discussed have been set the same as for the
full version and the FolderDialog component is in the component
package, which works fine for the full version.
It seems so illogical that the DCR file is needed, it is located in
the FolderDialog source dir, but it does help if I add that to the
project search path, but why should I have to do that for this single
folder and only for the demo project? Makes no sense....

This is about separating Designtime packages (and logic) from Runtime packages.

Normally you would build a Runtime package first. Let's call it 'MyCompRTPackage190'.
This package contains the source and .dcu files that you point to in the appl. project.
The source files should not contain the Register procedure nor the {$R *.dcr} directive
(which was the norm in the olden days). The package should be built as Runtime only.
Select Options in the right click context menu of the project manager and go to
Description in the Options dialog. Select Runtime only under Usage options.

Normally you would then build a Designtime package which only deals with what's
needed for the IDE. Let's call it 'MyCompDesignPackage190'. This package would require
MyCompRTPackage190. The only source file that is needed in a basic Designtime package
is the unit contaning the Register procedure (MyCompDesignReg.pas). The .dcr is placed
in the folder structure of this package. The package should be built as Designtime only.
Select Designtime only under Usage options. Do not point to anything from this
folder structure in your appl. project.

For example:

unit MyCompDesignReg;
 
interface
 
procedure Register;
 
implementation
 
{$R *.dcr}
 
uses
  System.Classes,
  MyComp;
 
procedure Register;
begin
  RegisterComponents('Bosse', [TMyComp]);
end;


This should fix the problem if done right.
I remember though reading a post where someone had additional problems in XE7,
but have forgotten what it was.
--
C-H
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02