-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DLL: Missing extern in global variable declarations in libfmapi/libfmapi_class_identifier.h #7
Comments
Note that libclocale and libcnotify have the same problem with their |
Note that per README this is an experimental library. Also why do you need this library as a DLL? For which specific compiler/linker and version and options are you experiencing issues? (given that different compilers/linkers and options have different behaviors). |
liblocale and libcnotify aren't experimental, and they have the same problem. libpff isn't experimental and it depends on libfmapi. If you're going to use a compiled library with Python on Windows, you need it as a DLL. I ran:
The linking command for the DLL was:
gcc version:
Here you can see that the
With everything else unchanged save for correcting the use of |
libpff uses libfmapi as a static library, how would you run into this issue? |
libpff doesn't need to link statically---it can link to a libfmapi DLL without any problems once the incorrect use of |
I've created PR #8 for you, which fixes the problem. |
that is not the way it comes configured.
Aren't you now telling the linker to get the data from libfmapi during build but not actually getting this information at run time? |
I don't believe so. What specifically makes you think that? |
Because it is comparable to the way a Windows static library exports its function and variables |
What way are you referring to? Can you point me to some reference for it? So far as I know, (I've been using the patch I provided when producing Windows static libraries for several yeas now, and haven't encountered any issues with it. If there is something I'm doing incorrectly, I'd appreciate being made aware of it.) |
what do you mean with "Windows export" do you mean DLL exports? https://github.com/libyal/libfmapi/blob/main/include/libfmapi/extern.h unless you define This is included in https://github.com/libyal/libfmapi/blob/main/libfmapi/libfmapi_extern.h your PR just move externs around, but technically you are using the same definition as the static version of the library. given that you are using mingw libtool is also involved.
I'm not saying that you will have issues, I'm telling you, you are basically using the library as static for the variables with the proposed changes. So your changes are not needed, just use libfmapi as a static library. |
I was paraphrasing what you said here:
I was hoping you'd tell me what you meant by that. I would still like to know what you were referring to specifically. Maybe an example would help clarify?
My PR does not just move
That's not correct. |
My framing was very different, i was not saying "Windows exports" I was saying "a Windows static library".
For a DLL correct, see https://learn.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-declspec-dllexport?view=msvc-170 for context that means That means there is no value to try to use libfmapi as a DLL for your purpose at this point. |
We're clearly not communicating here. I'll try again on Monday to give the clearest, most concise explanation I can of the problem and its solution. |
Maybe explain what you are trying to accomplish. For now I only see changes because you want things to be done in a certain way, without added value, and making maintenance more tedious. |
Would you explain why you think the patch makes maintenance more tedious? |
If you talk about communication break down you are not providing me the details I need. I unfortunately do not have the time to debate this indefinitely. You either provide me the information or I'll just close this out as something I currently don't have time for. |
I'll answer your questions the best I can:
|
Then why mention it to begin with? Why not clearly communicate to begin with? Why waste my time? Also I would disagree that DLL/shared library is not relevant, the code path you highlight includes DLL export/import.
This will create a DLL given behavior of configure. Libpff CI test show no issue with the current approach https://ci.appveyor.com/project/libyal/libpff/build/job/0jc8kloe7jcn6ycx Now for DLL specifically adding the extern keyword with the dllspec might be needed https://www.gnu.org/software/libtool/manual/html_node/Windows-DLLs.html But as you can see in the example this has different cases for different compilers/linkers.
Not sure what you intend to say with this, or what value it ads to solve this issue. It comes across as pedantic/arrogant especially in combination with "MUST be declared". Is that the change you want to see in the world more pedantic/arrogant people that push their option? Your patch might fix whatever problem you are trying to solve. Which you have not clearly explained to me, besides stating what MUST or MUST NOT. However as maintainer how am I sure it does not break anything else? Also the proposed changes litter the code with more extern keywords instead of fixing LIBFMAPI_EXTERN and LIBFMAPI_EXTERN_VARIABLE. I'll close this issue and will take a look to change the code to match https://www.gnu.org/software/libtool/manual/html_node/Windows-DLLs.html when time permits. |
Fair enough. I've done a terrible job of explaining this. I'll try again on a separate issue and open a new, cleaner PR. |
"MUST" is referencing the language used in RFCs. There's no reason to take offense at it. I was simply trying to express that all of my comments are offered in a spirit of helpfulness. As I've benefited from your software, I feel it's my duty to try to be helpful in return. I'm saddened that you don't see it this way. |
A lot of projects have descriptions of how to report bugs, designed to save everyone time. You don't have one, so I gave you the kind of bug report I would want myself as a maintainer. Maybe you could write a description of how to report bugs for your projects, to save everyone time? |
Let's say that my experience is that most people ignore the template and relevant documentation.
Understood, but this is the hard part of communication and best with asynchronous issue reports to stick to facts way and to provide the necessary context.
In plain English "MUST" looks very different. How would one know you are using language from a specific RFC? I can strongly recommend to leave as little ambiguity as possible especially when you are talking to an international audience. Stick to neutral plain English (no metaphors) and be aware that details and/or nuances are easily lost.
No offense taken, I'm just giving feedback on how it comes across.
For now no need, as I indicated this project is experimental. So it will likely change. What will benefit me at this stage is to understand your use case, given that in its current form the things you highlighted before are not causing issues for me. |
In that case, I will provide patches for several of the projects which are not experimental, as well. |
I would recommend to wait with that and explain your use case(s) first. I'm wary for changes that are mostly because of someones preference. |
In order to help me know how to explain my use case, would you please identify which of the following you disagree with?
Knowing where we disagree would help me focus my explanation. |
I'm thinking in much more basic terms. How are trying to use libfmapi (or other libyal libraries) if so:
|
I'm using libfmapi from libpff, building in five configurations---as shared libs for Linux, as 32-bit Windows DLLs, as 64-bit Windows DLLs, as 32-bit Windows static libs, and as 64-bit Windows static libs. There is no license, as this is for internal software which isn't being distributed. I have answered your questions. Would you please answer my question? |
Which question? Do you mean "In order to help me know how to explain my use case, would you please identify which of the following you disagree with?" You last comment comment just explained your use case. The thing I don't understand that if you are intended to use libpff, why do you need libfmapi as a stand-alone shared library? Currently the recommended configuration is to build libfmapi as static into libpff. It is not yet ready to be intended to be used as an independent DLL.
If this is a public header maybe, also for a DLL
You appear to very obsessed about wanting to call it a bug. The code is experimental, not finished, where does it say your use case is supported? Now I finally understand what you are trying to accomplish, why not define However a question that I need to answer first, if this is really the desired API for libfmapi to have. |
Yes, that is the question I wanted you to answer.
You can run into linking problems involving multiply defined symbols if you build libpff into libfmapi but then also link to libfmapi because you're using it directly.
Wouldn't it be nice for DLLs to work correctly? That is part of why I am offering you this patch. I have a few more I could also give you for building DLLs if you'd like them.
This answers my question. You're mistaken about what Variables declared in the global scope in private headers also need to be declared Consider what happens if you have a variable declared with
I will give you a patch on Monday which follows the libtool example. What they've done is not optimal for maintainability in my opinion, as noted above, but it is correct.
Neither the patch I've given you already nor the one I will give you tomorrow have any effect on the libfmapi API or your ability to adjust it. |
you mean link libfmapi into libpff? You can also run into linking problems when using shared libraries.
You incorrectly interpret my answer. I'm not saying anything about needing to use extern or not. I'm saying that depending on the private usage the variable does not need to be included in the global scope.
Then I recommend getting that updated first. |
I had not understood until now that you were talking about variables being removed from the global scope. We're in agreement that those should not be I've opened a second PR, #9, this time following what the libtool docs recommend, as per your preference. |
I've opened libyal/libclocale#8 and libyal/libcnotify#5, which fix the same problem in libclocale and libcnotify, respectively. |
Several global variables are declared in
libfmapi/libfmapi_class_identifier.h
, such asBecause they are declared in a header and thus cannot be defined there, each such variable needs to be declared with the
extern
keyword.The
LIBFMAPI_EXTERN_VARIABLE
macro is defined in `libfmapi/libfmapi_extern.h':In some cases,
LIBFMAPI_EXTERN_VARIABLE
is defined to beextern
, and in some cases to be whateverLIBFMAPI_EXTERN
expands to.LIBFMAPI_EXTERN
is defined ininclude/libfmapi/extern.h
:In the case where
LIBFMAPI_DLL_EXPORT
is defined,LIBFMAPI_EXTERN
will be__declspec(dllexport)
, which does not containextern
, so in that caseLIBFMAPI_EXTERN_VARIABLE
will also not containextern
, thus leaving the global variables inlibfmapi/libfmapi_class_identifier.h
declared incorrectly.As global variables declared in header files need to be declared
extern
in all cases, it would be more straightforward and less error-prone to declare them to beextern
unconditionally at the site of declaration.Additionally, since functions have extern linkage by default, it's not clear why the
LIBFMAPI_EXTERN
should ever containextern
at all---functions never require it, and global variables always do. TheLIBFMAPI_EXTERN
macro should probably be renamed so that it reflects its actual purpose, which is to act as as switch for__declspec(dllexport)
and__declspec(dllimport)
.The text was updated successfully, but these errors were encountered: