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

Cannot link DLL with static (non-import) library on Windows #1221

Open
nmfisher opened this issue Jun 25, 2024 · 2 comments
Open

Cannot link DLL with static (non-import) library on Windows #1221

nmfisher opened this issue Jun 25, 2024 · 2 comments

Comments

@nmfisher
Copy link
Contributor

When building a DLL on Windows, linking with a static .lib (i.e. not an import library) requires the library names to come immediately after the /link flag. There's no option in RunCBuilder that accommodates this. This isn't an issue on other platforms as we can pass everything via the flags argument (e.g. -lsomelib or -framework someframework), but that doesn't work with cl on Windows (or at least, I haven't found a way to do so; I have fairly limited experience with Windows command line tools).

Here's my current workaround:
nmfisher@7d9036b#diff-3be70b0004f01804719416f1e5931eaa8e2d618280bb0f9fa9bdaf2edc468964

This was just a quick hack which is why I'm not submitting as a PR, if you have any preference for the best way to address this, let me know and I'm happy to put one together.

@dcharkes
Copy link
Collaborator

Thanks for the report @nmfisher!

This helper lib is just in its infancy, so we welcome all contributions!

Maybe we should turn linkWith into -l for the other platforms. Yes it will be duplicate with flags, but we'll likely end up with duplicate ways to do something anyway (e.g. a separate frameworks option was suggested in #1228 as well).

Also, to make this into a PR:

  • It should be also used in an executable?
  • Can it be used in a static library?
  • And it should be covered by a test that fails if the linkWith is not set.

@nmfisher
Copy link
Contributor Author

Thanks @dcharkes. I'm a bit swamped at the moment but I'll try and put together a PR in the next week or two.

richyo-codes pushed a commit to richyo-codes/native that referenced this issue Oct 16, 2024
this is required for linking with libraries on Windows msvc. Hope to port to
other platforms as well.

dart-lang#1221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants