Solved

BCB DLL

Posted on 2000-04-22
22
363 Views
Last Modified: 2013-12-03
Hi!
Can anyone explain me how I can build DLL with Borland C++ Builder (4 or 5) so export functions will be without underscores? Thanks.
/kooper
0
Comment
Question by:abondar
  • 9
  • 6
  • 5
  • +1
22 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2740015
You'll have to include a .def file in your project which lists the export names of the functions, e.g.

LIBRARY mydll

EXPORTS

function1
function2
0
 

Author Comment

by:abondar
ID: 2740262
How this DEF file will contribute the DLL has export function names without underscores?
0
 
LVL 86

Expert Comment

by:jkr
ID: 2740299
The .def file instructs the linker not to generate the underscores for the export names of the C functions. The 'C' naming convention usually generates this underscore. However, when such a function is listed in the module definition file, it is exported using the exact name.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2740791
You shouldn't do anything.
By default, all functions are exported without underscore.

For example,

1) File->New->Dll

2) insert the function:

-------------------------------------
int __export aaa(DWORD a)
{
        return 1;
}

3) Make the project

4) Run
      tdump <dllname.dll>

You'll see that the exported name is "aaa".


0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2740806
Using __export eliminates the need for an EXPORTS section in your module definition file.

To make your dll like the standard windows dlls,

Define your functions as follows.

__declspec(dllexport) int WINAPI aaabbb(DWORD a)
{
        return 1;
}

The declaration in the header file for the dll must be

extern int WINAPI aaabbb(DWORD a);
0
 

Author Comment

by:abondar
ID: 2744062
Adjusted points from 200 to 300
0
 

Author Comment

by:abondar
ID: 2744063
How I can export variables and functions with variable parameters list without underscores? __stdcall (=WINAPI) is not works here! Any suggestions are appreciated. Thanks.
0
 
LVL 86

Expert Comment

by:jkr
ID: 2745128
Did you try the .def file? It's the only way to *ensure* that your exported functions are named exactly way you want...
0
 

Author Comment

by:abondar
ID: 2745320
Yes, I have tried it. But this case symbols appears both form - with and wintout underscore. But I would like to see symbol into the DLL/OBJ file once and exactly without underscore!
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2745342
DEF file will not help for OBJ.
0
 

Author Comment

by:abondar
ID: 2745452
Yes, I understand. So how I can make symbols without underscores into the OBJ file?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 15

Expert Comment

by:NickRepin
ID: 2745523
Project -> Options ->Advanced compiler -> Output group -> Generate underscores.
0
 

Author Comment

by:abondar
ID: 2745623
Yes, you're right. But in this case a lot of functions like memcpy(), malloc(), free(), strlen() etc. could not be resolved with standart BCB libraries!
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2745813
Your question is still locked by jkr's answer. So I'm not sure that I have to answer on your questions in my comments.

You have to move all functions, which you want to make without an underscore, into a separate .cpp file. Then place the following line on the top of that cpp file:

#pragma option -u-

extern "C" int nounderscore(int a,...);
__declspec(dllexport) int nounderscore(int a,...)
{
}

// other functions.

0
 
LVL 86

Expert Comment

by:jkr
ID: 2747152
Your Q was: "Can anyone explain me how I can build DLL with Borland C++ Builder (4 or 5) so export functions will be without underscores?"

We were not talking about object (i.e. intermediate) files. .def files are the way to do that, so my answer is definitely correct.
0
 

Author Comment

by:abondar
ID: 2747976
But during discussion I was need to get some adjustments to resolve my problem. NR's comments is more useful for me right now... Anyway I thank you for you assistance.

P.S. How I can divide points for the question between two experts if I whould like so?
0
 
LVL 86

Expert Comment

by:jkr
ID: 2748289
>>How I can divide points for the
>>question between two experts if I
>>whould like so?

You can do that by asking a Q in the customer service topic area at http://www1.experts-exchange.com/Customer_Service/Experts_Exchange/

BTW: Why is it impotant how these names are like in .obj files ? They're simply intermediate files...

0
 
LVL 3

Expert Comment

by:darinw
ID: 2749513
Community Support has reduced points from 300 to 150
0
 
LVL 3

Expert Comment

by:darinw
ID: 2749514
Hi abondar,

I have reduced the points on this question to one half. Please accept one of the Experts comments as an answer. Remember, the Accept Comment as Answer button is in the header of the comment.

For the second Expert, post a question in this topic area. The new question title should be 'For ExpertName - 10332390' with the appropriate Expert name and it should be for 150 points.

For your convenience, you can use this link to create the new question:
http://www.experts-exchange.com/bin/NewQForm?ta=45

darinw
Customer Service
0
 

Author Comment

by:abondar
ID: 2751236
Adjusted points from 150 to 200
0
 

Author Comment

by:abondar
ID: 2751237
jkr.
Linker need to resolve external OBJ file references with DLL exports. So if OBJ has some external definitions with underscores it will not be resolved with DLL library file which has not underscores symbols.

Thanks.
0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 2752167
Well, as you didn't accept a comment as an answer as darinw proposed and regarding that I answered your original question, I'll simply lock this again...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now