?
Solved

Borland C++ Builder : How to release my code to others.

Posted on 2000-01-20
28
Medium Priority
?
637 Views
Last Modified: 2012-08-13
This seeems to be a repeat of PAQ.10052127, but the solution given there doesn't help.

Basically, when I build a project on my machine, the .EXE runs ok as standalone (not from withing C++ Builder), but when I give it to someone else, they get an error "a required DLL is misisng".

I though that the answer was that given for the question above - Project/Options/Linker/uncheck 'Use the dynamic RTL', but the problem still persists. Any ideas?

btw, please post comments & leave it to me to invite an answer when it works.
0
Comment
Question by:graham_k
  • 7
  • 6
  • 6
  • +4
28 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2370114
Rebuild All?
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2370151
As with MS, when I install the MS Visual C++ environment it installs things like the MFC.DLL.  Now if in my project I define not to statically link in the MFC library then any machine that wants to run my program must also have the MFC.DLL on their machine because it is attempting to load the required code at run time.

Solution. You should have a choice of linking in the code statically or dynamically, if you choose static then the EXE will run without any depenancies on other DLLs, if you choose dynamically then you will need to write an install script that installs on each machine your program and the required DLL.\\

Regards,
Dave
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2370162
Oh ya, one more thing, if you choose static linking the static text size of your program will be much larger, if you choose dynamic linking then the exe will be much smaller.

Edit your make file via setup for your project, not sure what platform you are using, to add the static or dynamic linking option.



Dave
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 22

Expert Comment

by:nietod
ID: 2370229
The problem may not be the RTL DLL.  So A) statically linking to the RTL may not solve the problem and B) I find that it is often (not always) a bad idea to statically link to the RTL.   There is no real dissadvantage to dynamically linking to the RTL, except that you have to remember to ship the RTL DLL with your program, so I would really suggest you do that.

To solve your problem, you need to find all the DLLs that your EXE uses.  VC comes with a utility called "depends" that does this.  You might want to see if Borland ships a copy.

If that does not work you can right-click on the EXE in the explorer window and choose "quick view" from the pop-up menu.  This produces a report that will list all the DLLs used by the EXE.  Except for the operating system DLLs (Like Kernel, User, GDI) you will need to ship all these DLLs with your app.  Furthermore you need to use this technique to look at each of the DLLs that you are sending and see if they need any DLLs
0
 

Expert Comment

by:Toronado
ID: 2371075
Hi graham_k

If you don't have the depends mentioned by nietod tool, somewhere on the www.codeguru.com site is a tool called "Display loaded modules" which showes all the loaded dll's. Including kernel dll's

Regard,
 Toronado.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2371079
There's a nice tool, dll-view, from sys-internals, http://www.sysinternals.com/ that may help
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2371218
The proposed question I believe has been answered.

Why can I compile and run my app on my development machine, but it does not run on another machine?

Because the required DLL are missing on the other machine. An answer was provided by me and nietod. So, what gives??
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 2371345
Remember that runtime packages are also dynamically linked.
Could it be that the required dll is the runtime package for the VCL or other packages that you use?

Quote from the help ...
"The Runtime Packages option determines which run-time packages to use when the executable file is created. A runtime package is a special dynamic-link library used by C++Builder to provide functionality when a user runs an application."

It is however usually better to ship all the dll's needed. Most people keep a "clean" machine to test distributions but with the above mentioned utilities you should be able to get them all. Just make sure to check the 2nd and 3rd level dependencies (i.e. the DLLs needed by those DLLs)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2371826
>> So, what gives??
Well, if you're wondering why the question isn't closed, well, no one has answered.  You were here first and your answer basically correct--other than we dissagree on some opinions--so you probably should answer.

>> just make sure to check the 2nd and 3rd
>> level dependencies (i.e. the
>> DLLs needed by those DLLs)
The quickview utility does not show these dependancies, so you have to track them down by manually finding and opening the other DLLs.  But the "Depends.exe" utility does this for you and I expect that the dll-view that Kangaroo suggested would do so as well (guessing).
0
 
LVL 23

Expert Comment

by:chensu
ID: 2372094
Depends is a utility of the Platform SDK, which can be downloaded at

http://msdn.microsoft.com/developer/sdk/platform.asp
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2372739
There is more than one answer so I will provide 2.

1. If you want to dynamically link in some or all of the libraries that your exe is using then insure that the DLLs exist on the target platform. Otherwise your program is going to complian at run time.

2. Recompile the program and statically link in all required libraries so that the exe can run independant of them. There are advantages and disadvantages to doing this.

3. If any of the statically linked in libraries require DLLs, then you will need to insure that they also exist on the target platform.

Regards,
Dave
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2373618
I think it does, at least it shows a lot more DLL's then QuickView.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2373628
And you can save the result to a text file
====================================================================================================================
Process: C:\WINDOWS\UTILS\PFE32.EXE Pid: FFF81E55

Base             Size             Version          Time             Path
0x400000         0x9D000          1.01.0000.0000   31/01/1999 10:13 C:\WINDOWS\UTILS\PFE32.EXE
0xBFE30000       0x10000          4.00.0000.0950   24/08/1996 11:11 C:\WINDOWS\SYSTEM\WINMM.DLL
0x65F00000       0xBC000          4.71.1718.0000   18/11/1997 0:00  C:\WINDOWS\SYSTEM\OLE32.DLL
0x7FDC0000       0xCB000          4.00.0000.1111   24/08/1996 11:11 C:\WINDOWS\SYSTEM\SHELL32.DLL
0xBFB90000       0x70000          4.72.2106.0004   18/11/1997 0:00  C:\WINDOWS\SYSTEM\COMCTL32.DLL
0x7FE90000       0x1B000          4.00.0000.0951   24/08/1996 11:11 C:\WINDOWS\SYSTEM\COMDLG32.DLL
0xBFF60000       0xF000           4.00.0000.0950   24/08/1996 11:11 C:\WINDOWS\SYSTEM\USER32.DLL
0xBFF30000       0x25000          4.00.0000.0950   24/08/1996 11:11 C:\WINDOWS\SYSTEM\GDI32.DLL
0xBFED0000       0xE000           4.71.0118.0000   18/11/1997 0:00  C:\WINDOWS\SYSTEM\ADVAPI32.DLL
0xBFF70000       0x67000          4.03.0000.1212   10/04/1997 12:14 C:\WINDOWS\SYSTEM\KERNEL32.DLL
0
 
LVL 6

Author Comment

by:graham_k
ID: 2373631
well, guys, as usual, I wasn't as explicit as I could be in my question.

To be explicit :  the misisng DLL is VCL40.BPL. I would *very* much like to be able to ditribute *only* a .EXE.  Can anyone who is actually using Borland C++ Builder (V4) tell me how to do this?
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2373960
The originally proposed question has been answered so i don't think that it is fair that my answer was rejected. Graham, when you ask a question you should insure that you are specific so that we don't waist our time out here.

I don't care if you have Borland C++ builder, or Jimmy Bobs Build It in YOUR BackYard compiler, the answer is simple. To provide a stand alone EXE you will have to STATICALLY link in the VCL40.LIB, and any other libraries that are being dynamically linked in. Most good development platforms like MS Visual C++ give you these options when you create your project. You can also simply edit your makefile and add these libraries manually. If Borland C++ Builder comes with a Project SETUP (and i am sure it does) then you need to set this option in the project setup.  Not sure what else to tell you.

0
 
LVL 22

Expert Comment

by:nietod
ID: 2373971
I do see options in C++ Builder 4 for linking statically to the RTL, but I don't see options to link statically to VCL (Borland's GUI library).  Unless I messed something, you must ship the VCL DLL or you must not use VCL.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2373989
hi Nietod, since you actually have C++ Builder 4, could you please knock up a quick .exe (new project/build would do it), with project/options/linker for static linking & see what happens on a 2nd pc?

I suspect that it will prompt for vcl40.bpl, which is what is happening to me.

At that point we will have defined the problem & proved it unsolvable, then I can begin agonizing over who gets what points :-)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2374127
Yes, it uses VCL40.BPL (also USER32.DLL and KERNAL32.DLL).

I didn't move it to another machine, but there is no need.  It will not work on any machine that doesn't have VCL40 installed.

>> we will have defined the problem & proved it unsolvable
I think we already defined the problem and we proved it solvable, if you are willing to distribute VCL40, that is.  I there some reason you don't want to distribute it?  

Note also that there might be an option to statically link with VCL, but I couldn't find one, and I checked again.

Kangaroo,Your seperator line needs to go on a diet, this quetion is too wide now.  :-)
0
 
LVL 6

Author Comment

by:graham_k
ID: 2374245
hmmm, I really wanted to distribute the .EXE only. Well, I suppose that I will eventually be making an install with readme, help ffiels, etc. So, I'll just have to live with it.

dhymes & nietod, you each get 50 points. one of you can lock this & I'll post a question for the other.

Still seems like a damned pity, though, that I can't just create a .EXE    :-(
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 2374257
I'll answer here.

FYI there is now a link at the top of  a comment box to accept tje comment as an answer, you could have used that instead.
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2380906
graham, did  you post the other question yet?
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2380971
I see :(
I really think they should use a fixed width font on this site.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2381018
"dhymes" graham, did  you post the other question yet?

I have done now.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2510937
hmm, gysbert1 should have had the points. I finally found out what I was doing wrong.

The dynamic/static thing is two step. In addition to Project/Options/Linker/uncheck 'Use the dynamic RTL', one needs to Project/Options/PAckages/uncheck 'Build with Runtime Packages'.

I leave this here for future generations/anyone else with the same stupid problem.

If gysbert1 is still tracking this question & wants some points, he only has to ask.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2511120
I see.  

VC shipps with a great program called depends.exe that helps diagnose these problems.  It looks at your EXE (or DLL) and lists all the DLLs that it uses, this continues recusrively, that is then looks at all the DLLs used by the DLLS your program uses etc.  So it gives you a tree of  your DLL dependancies.  Very handy in solving this sort of problem.  BCB might come with a similar utility, it is worth looking into.
0
 
LVL 6

Author Comment

by:graham_k
ID: 2511170
no it's not (worth looking into). It's just a stupid RTFM oversight :-)

I understand what you're trying to say, but this is way simpler than that. When you fire up B C+++ Builder, it has an empty form. If you build & run that, simple stuff like the close/enlarge/shrink buttons work. Even releasing something like that would encounter the problem - which could be easilly solved by a bit of RTFM :-)

Don't worry - I don't want the points back   :-)    <g>     :-)
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 2518799
I am still tracking and am glad your problem is solved.

I was off-line for a while as I tried (unsuccessfully) to change my e-mail address on the system (that had expired) to my new address ... Otherwise I could have cleared this up earlier !

No need to give me any points though.

For more future reference:

That option is really badly documented and well hidden in the Borland IDE and the first time I had to use it it burnt me as well !

For some reason they decided to call the libraries packages. If you realise that you eventually figure out that you have to change the packages settings to link statically.

If the library is not a Borland-type package you have to add the .lib to the project to link it statically. You can use implib (that ships with borland) to obtain static linkable (.lib) versions of any .dll you have and then add the resulting .lib file to you project to link statically but that is for non-borland .dll's (thus not .bpl's)

0
 
LVL 6

Author Comment

by:graham_k
ID: 2518862
yes, I finally got it sussed. But only after reading it in a BC++ book, not by any help from Borland/Inprise(/Corel !). I'm going to post you some points anyway, since it seems that I erroniously awarded points to 2 others on this question, it wouldn't be the right thing to deny them to the only person who actually got the answer (anyway, I'm flush with points).

Thanks again
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question