link obj files in embarcadero c++ builder Dunit Test Project - c++builder

I'have added a test case to DUnit Test project in embarcadero c++ builder 2010. I can compile it fine but the linker fails saying "unresolved external" to a method in an .obj file from original project. If I add the .obj file to DUnit project it works fine. However I don't want to do it as there are huge number of .obj files in the original project and it will be a pain to add .obj files each time you want to test a new class. Is there a way to point the linker to search directories to look in for .obj files and get them from there. ( I'm not using the command line, but the c++ builder 2010 IDE).

If you go into Project Properties you can configure the directories that are searched for includes, libraries, etc. You can do this by build type or for all configurations.
However it's usually a bad idea to directly link other .obj files from a different project, as they may have been compiled with different settings . Why don't you just add your test case to the project without deleting anything from it?

Related

Delphi package compiles without the finding the unit file of a referenced type?

Today I'm trying to figure out why something works when I think it should be broken.
I have little Delphi experience, and I've inherited a Delphi codebase and am setting up a machine where it will be maintained and compiled. I have a package that compiles successfully but can't figure out how it is resolving one of the types. My understanding is that when you use a unit, you must either
Include the source file in your package directly
Resolve the source pas or dcu file on your project search path
Resolve the source pas or dcu file on your IDE library path
None of these appear to be happening, and yet the package compiles. How else could this be compiling successfully?
Details
I have 'base' package that has a direct include on the file THotLog.pas. The file appears under the project's Contains folder in Project Manager. THotLog is NOT one of the components in the package, it is not in the register procedure for base package.
I then have 'consuming' package that requires base package. Consuming package has several components with THotLog members, and consuming package compiles. This surprises me, because I thought consuming package would have to be able to locate THotLog.pas or THotLog.dcu.
This is for RAD Studio 10.1. The project search path (Project > Options : Search path) is empty, and the IDE search paths (Tools > Options , then Environment Options > Delphi Options > Library) do not include where THotLog is.
I've also tried renamed all THotLog files on the hard drive and consuming package still compiles.
Hypothesizing that my understanding about type resolution is wrong, I tried making a set of sample projects with a similar layout and the sample consuming package cannot resolve sample THotLog without locating the pas or dcu file.
When you build a Delphi package, the compiler/linker creates a Compiled Package File named [package-name].dcp. It is a binary file containing all of the compiled units included in that package.
Compiling your "base" package created a [base-package].dcp file that is visible to the "consuming" package. The "consuming" package is referencing the base-package in its "Requires" section; this is the link to the base package's DCP file.
Delphi Compiled Package File

Delphi: Missing Dcu

[DCC Fatal Error] Unit1.pas(7): F1026 File not found: 'MyBitBtn.dcu'
Unit1 is a VCL Form for test purposes.
I have installed a design time package which contains a custom component that derived from TBitBtn. I can load the MyBitBtn in the Delphi IDE, load up the custom images I coded in design time and it seems like it works fine, at least visually. I get the above compile time error when I try to compile the test project.
I have a package group that has one design time package and one run time package. Design time package registers the component and Runtime package inherits the TBitBtn and has the custom code in it. The design time package contains the RunTime DCP file in the requires section.
The moment I insert the custom button on the test form, IDE creates the USES clause for MyBitBtn file. And that file apparently can't be found. Shouldn't that be part of the package installed?
Most probable you did not set 'Unit output directory' option in your runtime package, so package .dcu's are not available; I usually set it to $(BDSCOMMONDIR)\Dcp and have no problems.
Generally, the .dcu's of a runtime package should be available via global IDE library path if you want your package to be available to any project:
.
You should either use one of the existing paths or add your own.
The design part works, but for run time, the compiler must be able to find the dcu.
You can do that either...
By adding the dcu folder to the library path of the IDE.
By adding the dcu folder to the search path of the project.
Or by adding the dcu explicitly to the project.
I would choose the first option. Since it's an installed component, you would want it to be available for any project, so setting the library path makes the most sense.
define the path where this dcu is stored in system environment. And dont forget to include it in Delphi env paths.
Go to ZEOS files, open packages, choose your version(DelphiXE10/Delphi7 ...) then go to the Win 32 file, open it and open Debug folder. Copy every thing, go to Program Files, Embarcadero, Studio, 17.0, lib, Win 32, Debug and paste, do the same in every win32 folder... Hope it helps :)

How do I make my changes to XML-related source files take effect?

I want to make changes to the xmldom and XMLDoc files. I tried to, but I don't know how to test those changes because the program does not seem to be running the code in those files. I tried using a ShowMessage to see if that code was being accessed but it never showed up. Even if I rename the directory the files are in, the program still compiles fine as if it is not actively reading the files at run time but instead has the information stored elsewhere.
How can I change these namespaces and then make sure that the changes are being included in my next compile?
Update
Well i'm looking for an answer in general.. Because I have had this problem in multiple situations.. But for specifics Changing XML node attribute value gives "Namespace error" (here the answer talks about changing the 'AdomCore_4_3') I want to be able to change it and have the change show up when I compile.
If you've removed the compiled DCU files from your environment, and your changes still aren't being compiled into your project, then you either aren't really using those units at all, or you have run-time packages enabled.
With run-time packages, the compiled code is accessed from the BPL file, not the DCUs. You're not allowed to distribute modified BPL files, so if you're going to modify the Delphi-provided source code, you need to make sure you're not linking the package with the XML units to your project. You can control that in your project's linker options.
As long as you are not making changes in the interface section of the units, only the implementation section, then you can disable use of Runtime Packages in your Project Options and then add the modified source files directly to your project. The compiler will compile them into new .DCU files and use them instead of the default .DCU files.

recompile/rebuild Delphi 5 code using .dpr file

I am trying to recompile/rebuild an old application program developed on Delphi5. I used the same Delphi5 software on an XP computer.
I did some minor corrections to the codes of a couple of forms and units. When I recompile using the .dpr file it comes with a fatal message: File not found System.pas
I added in .dpr file on the link path to this file BP folder. No success and the same message. Any clue will help.
Probably Library Path is broken after running some buggy component installer. In modern IDE's look for Tools -> Options -> Library -> Library Path from main menu (should be slightly different for Delphi 5).
System.dcu file lives in $(BDS)\Lib path for Delphi 2007.
The "File not found System.pas" error often isn't really because it can't find system.pas. It's some other problem that manifests as this error.
It can be:
Duplicate Path entries in the Library Path.
Too many entries in the Library Path - I think the limit is 99.
Path to a package in Library Paths too long.
Path to a package in Library Paths corrupt.
Environmental Variables not set correctly.
and possibly more if you Google "system.pas not found"
Marjan is right.
But also add ${DELPHI}\LIB\OBJ
If you still have a dcc32.cfg with the project, or a .cfg with the project, open it up to see if the settings in there are correct. Otherwise delete the .cfg or edit it to reflect the proper path to the bin and bin\obj directories.
A .dpr file is the main project file for a Delphi 2,3,4,5,6,7 project.
You have not given any details like WHAT WAY OF BUILDING SOMETHING of delphi you're using (the code is Delphi 5 level code, but you are not telling me for example, if you built the project inside the Delphi IDE or from the command line compiler DCC32), and what other files you have installed. You haven't mentioned if the library paths and so on are configured (either for the IDE, or for the command line environment, both of which are separate tasks).
An inability to find System.pas suggests to me that you might be running the command line compiler (Dcc32) instead of the IDE to build the project, and you have forgotten to mention that. That usually means you have to set up the Options (dcc32.dof) file for Delphi, so that command line building with Dcc32 can work.
What exactly do you mean by "When I compile with the .dpr file"? Instead of making people guess, show the commands you typed, exactly, and the error message, exactly. If it helps, use screenshots or text grabs.

Inter-project dependencies

I'm doing some Delphi (2010) work this summer, and I've stumbled upon this problem:
My project consists of reusable backend library and a bunch of GUIs that tap into its interface. In this circumstances I've decided to make the backend and GUIs separate projects within single project group (I hope my train of thought is correct). The problem is, how can I include units from the backend in a GUI project?
I've tried to modify Project Options > Directories and Conditionals but compiler still complains about being unable to find proper .dcu's.
Any ideas? Your help will be appreciated.
In D2010, the Directories and Conditionals in the project option refers to (and is specific for?) the resource compiler.
I guess what you are looking for is the Project Options->Delphi Compiler->Search Path
Search where the compiler is generating the DCU files. (2)
In project options you must add the source directory on you have de PAS files (1) or the directory where compiler generate de DCU files.
(1) In the "Search path" edit.
(2) This directory is the "Unit Output Directory" edit.
Regards

Resources