Skip to content
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

Fix windows build by exporting public static const class variables #491

Conversation

Levi-Armstrong
Copy link
Contributor

No description provided.

@Levi-Armstrong
Copy link
Contributor Author

@johnwason I believe this should fix the windows build issue in your open MR.

Copy link

codecov bot commented Jul 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.81%. Comparing base (18c0b5e) to head (c0b35a8).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #491   +/-   ##
=======================================
  Coverage   84.81%   84.81%           
=======================================
  Files         231      231           
  Lines       15737    15737           
=======================================
  Hits        13347    13347           
  Misses       2390     2390           

see 1 file with indirect coverage changes

@johnwason
Copy link
Contributor

The export is applied to the class, and each individual library needs their own export macro.

Here is an example of an export macro on a class:

https://github.com/robotraconteur/robotraconteur/blob/b0c1ccab189b059f3b59874a303a6a6f52e321d7/RobotRaconteurCore/include/RobotRaconteur/DataTypes.h#L250

I can take a look this week.

@Levi-Armstrong
Copy link
Contributor Author

I thought everything would get exported when using cmake WINDOWS_EXPORT_ALL_SYMBOLS and only these need to be exported manually.

@johnwason
Copy link
Contributor

The module definition file will be passed to the linker causing all symbols to be exported from the .dll. For global data symbols, __declspec(dllimport) must still be used when compiling against the code in the .dll. All other function symbols will be automatically exported and imported by callers.

https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html

Data symbols still need to be exported. For classes with static fields I think the entire class needs to be exported but I haven't used this before.

@Levi-Armstrong Levi-Armstrong deleted the feature/windows-export-static-variables branch July 29, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants