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 C API Tests #4

Merged
merged 24 commits into from
Mar 30, 2020
Merged

Fix C API Tests #4

merged 24 commits into from
Mar 30, 2020

Conversation

Myoldmopar
Copy link
Owner

I think I can make them work across all three platforms without modifying E+.

@Myoldmopar
Copy link
Owner Author

OK, C API working on Mac, Windows should be pretty easy actually.

@Myoldmopar
Copy link
Owner Author

ALRIGHT, calling it. This is now demonstrating the C API usage on all three platforms, but with varying capabilities.

(I use DLL as an alias for the shared library convention on all platforms.)

Linux

  • Python API script working
  • Eager C API linking works -- no need to copy files around, change working dir, or anything
  • Lazy C API linking works -- no need to copy files around, change working dir, or anything

Mac

  • Python API script DOES NOT WORK -- the root of the problem is that the libenergyplusapi.dylib file is set to look for the Python library at @executable_path/Python. This is problematic when you try to call the E+ API from Python, because @executable_path is going to be something like /usr/local/bin/ since that is where the brewed Python might be (for example). Could potentially try copying the Python lib out there, but that seems risky, and what we should really be doing is fixing up our API DLL to use rpath instead of explicit executable_path.
  • Eager C API linking works fine, but when running it, we have the same problem as with Python, it wants to load up the Python DLL immediately, so you need to copy the built up C program into the E+ install and it will run fine from there.
  • Lazy C API linking works - since we give it the explicit path to the E+ API DLL in the source code, it doesn't need to "find" the E+ API anywhere, however it still needs to "find" the Python DLL. So you have two choices - you can either copy the built C program into the E+ install folder and run from there, or copy the Python DLL from the install into the C build folder and run from there.

Windows

  • Python API is not set to run, but I think it will actually. That's for the next PR.
  • Eager C API linking does not work, because Windows will not link to a DLL at link-time, at least not the way we've built it. We need to use a DEF workflow when building, or provide a .lib file instead. I think.
  • Lazy C API linking does work, however, and quite well with numerous options for workflows:
  • Copying the C binary into the E+ install tree works, and you can execute from any working dir.
  • Running the C binary where it lives but changing working dir to the E+ install folder works.
  • Setting the PATH to include the E+ install tree, leaving the C binary in the C build folder, and running from that folder works fine.

Outcomes: Need to use rpath on Mac and package up the lib on Windows.

@Myoldmopar Myoldmopar merged commit 14270b6 into master Mar 30, 2020
@Myoldmopar Myoldmopar deleted the FixCAPITest branch March 30, 2020 19:54
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.

1 participant