473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Exporting function problem

Hello,

I have a strange situation where I'm trying to export a function in a class,
but it won't get exported. I actually have a couple of header and cpp files.
Each pair of header and cpp files contain a class and each class exports a
couple of static functions. In the one file, the class is properly exported.
I can verify this by dumpbin /exports. But the other class doesn't show up.

In my case, there's actually two projects involved. The first compiles to a
lib file. It's in this project where I export the functions. A second
project links to the lib file generated by the first project and produces a
regular MFC DLL. It's this DLL that I tried to view export functions from,
but functions defined in one file won't appear.

I modified the second set of header and cpp files so that they're nearly
identical to the working set; the only difference being the name of the files
and the class name. This didn't help. I then added similar second classes
(that export functions) to each pair of header/cpp files. For the original
working set, the second class appears. But in the case of the second set of
header/cpp files, nothing is exported. I compared the the properties on the
files as recorded in the .vcproject file for the two cpp files and they are
identical. I also did a visual comparison in the cpp file property pages and
could see no differences.

How is that one virtually identical file will properly export functions
while the exported functions in the second file will not work?

Thanks,
Notre

Oct 4 '06 #1
6 1401
I think I figured out what my problem is, but not how to fix it.

For the first pair of cpp/header files (the ones that work correctly), there
is at least one function defined in the class defined in these files that is
explicitly referenced elsewhere in the static library. For the second pair
of cpp/header files (the ones that don't export), none of the functions is
explicitly used in the static library or the DLL into which it is linked.

It seems that when the DLL is built, it optimizes out any code that is not
being referenced (even in debug build). This is true even though the file
has some exported functions. Once I reference a function that's defined in
the second file in some code that is being used in the static library,
suddenly the exported functions of the second class (in the second set of
files) appear. I think the object file generated from the second cpp/header
files is being optimized out, since it doesn't appear to the linker that it's
being used.

I've tried using the /OPT:NOREF linker setting (even though /DEBUG is set in
my debug build) but this doesn't fix my problem. I also tried to use /SYMBOL
but couldn't figure out the proper managled name, even after doing a dumpbin
/symbols on the static lib file. Any suggestions on how I can tell the
linker not to optimize out my files?

Thanks!!
Notre
Oct 4 '06 #2
Hi Notre,

Based on the description, the problem is the VC linker will cut off your
exported functions if they haven't been referenced in that dll project
itself. Please correct me if I misunderstand anything.

In order to research this issue, would you please provide a small
stand-alone sample project(zipped) for us to repro? You can send attach
that sample to your newsgroup reply message or send it to me directly.(just
remove the "online" of my email address alias)

Thanks!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 5 '06 #3
Hi Gary,

Your understanding of the problem is correct. I just found a solution today
that works.

I was using __declspec(dllexport) in the static library function that I
ultimately wanted to be exposed through DLL into which the static library is
linked. I had to add a module definition file (.def) to the DLL to which the
static library was linked, and explicitly define an entry in the module
definition file for the function I was trying to export. This feels like a
linker bug to me (it's ugly that I have to put in the long, managled name in
the .def file), but it's a solution to my problem.

Thanks,
Notre
Oct 5 '06 #4
Thanks for the update, Notre!

I am glad to know you have already worked around this issue. By the way,
for the VC++ problem, I suggest you can consult it in our VC relevant
newsgroups next time, you would get better and quicker help there.

Have a nice day!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 6 '06 #5
Thanks Gary. Which newsgroup would you recommend? I thought this one was
the right one...?
Oct 6 '06 #6
Hi,

Considering the export function is a native vc issue, I suggest you can
consult such questions in the microsoft.public.vc.language newsgroup.

Good Luck!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 9 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fran Zablocki | last post by:
I have a process that exports an Access table to a comma-delimited text file. One of the fields that is exported shows the date it was exported, using the Date() function. In the Access table, the...
2
by: Regnab | last post by:
I've got my code working so that it'll count the number of columns in the table and move across (eg Range A-P and then range Q-W). Problem is when I get to the end of the single letters and get...
4
by: Alexander Filatov | last post by:
I need implementing Windows Cluster Resource DLL, that requires me creating DLL exporting several functions. How it can be done in C#? Thanks, Alexander
2
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
2
by: Mux | last post by:
I am facing the following problem while exporting data to Word. The current implementation is as described below: I have a JSP file which has a link that enables you to export the data to Word....
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
0
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
hi, I trying to export data display on a gridview that supports any language (like chinese, japanese, thai, french) shown here is chinese only. There is no problem exporting english language...
1
by: cmgmyr | last post by:
Hey All, I'm having a little problem with exporting data from my database. The problem is that the query seems to be too much for PHP and MySQL to handle since it is timing out. I have the timeout...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.