• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

BCB DLL

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
abondar
Asked:
abondar
  • 9
  • 6
  • 5
  • +1
1 Solution
 
jkrCommented:
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
 
abondarAuthor Commented:
How this DEF file will contribute the DLL has export function names without underscores?
0
 
jkrCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
NickRepinCommented:
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
 
NickRepinCommented:
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
 
abondarAuthor Commented:
Adjusted points from 200 to 300
0
 
abondarAuthor Commented:
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
 
jkrCommented:
Did you try the .def file? It's the only way to *ensure* that your exported functions are named exactly way you want...
0
 
abondarAuthor Commented:
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
 
NickRepinCommented:
DEF file will not help for OBJ.
0
 
abondarAuthor Commented:
Yes, I understand. So how I can make symbols without underscores into the OBJ file?
0
 
NickRepinCommented:
Project -> Options ->Advanced compiler -> Output group -> Generate underscores.
0
 
abondarAuthor Commented:
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
 
NickRepinCommented:
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
 
jkrCommented:
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
 
abondarAuthor Commented:
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
 
jkrCommented:
>>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
 
darinwCommented:
Community Support has reduced points from 300 to 150
0
 
darinwCommented:
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
 
abondarAuthor Commented:
Adjusted points from 150 to 200
0
 
abondarAuthor Commented:
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
 
jkrCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now