?
Solved

BCB DLL

Posted on 2000-04-22
22
Medium Priority
?
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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
 
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 800 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

719 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