-
Notifications
You must be signed in to change notification settings - Fork 139
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
Dynamic link to dependency libraries #955
Comments
One possibility is to let the user to select the header file name and library file name for these dependencies libraries. So the user can easily select the static library (eg: libusb-1.0.a) or the dynamic library (eg: libusb-1.0.dll.a). |
Interestingly the "classic" release tarball (generated by auto-tools) will build the avrdude binary I want -- which means that it has dynamic link to the dependancy libraries.
However, CMake is using static libraries. Strange thing is that it is using dynamic library for readline.
|
So the hacky way for CMake is to change the build command to use dynamic dependancy libs.
|
Here are three versions of the avrdude 7.0 release 64bit Windows binary using MSYS2 mingw64 (CMake static, CMake dynmaic and auto-tools dynamic). The dependancies dll are also included. |
The resultant shared avrdude is working fine.
|
#962 is working for MSYS2 mingw32/mingw64 build -- either use static link or use dynamic link for all the dependancy libraries. For MSVC, #962 is not really working as we need to use the external custom libraries (libelf, libusb, libftdi and hidapi) which seem to only produce static libraries as of now. Still it will be great that users can define the option to link to static/shared lib individually (per library basis). For example, only use dynamic link for libusb-1.0, hidapi and libftdi1; and use static link to libelf and readline. |
#962 has been merged and the option to use static lib or dynamic lib was added. But it has not been implemented yet. @mariusgreuel wrote in the pull request comments.
|
For example, the default under Linux is dynamic linking.
On the other hand, Arduino build is already using static linking.
Ref: |
Same for macOS.
On the othe hand, the build from Arduino alreay uses static linking for macOS.
|
Take note the Windows MSYS2 mingw32/mingw64 build will have a dynamic link to libusb0.dll if you link to libusb-win32. Ref:
The solution for is to use libusb-compat-0.1 to replace libusb-win32. You can of course use the MSVC build for Windows as well which as of now only works with static linking. |
Arduino is using the following patch on top of avrdude 7.0 release to use static linking for Linux/macOS and mingw32. Maybe this can be adapted to the latest git so that user can select either static linking or dynamic linking for Linux/,macOS and mingw32/64 (not for MSVC). Take note #962 has been merged, so the changes need to be on top of that.
|
I think the patch may not work as it is already included in the main git tree.
And ineed it does not work. |
Edit: The following commands is good to build dynamic link version. This is very good.
Build log:
|
Indeed git main static link build for Linux and macOS failed. This may pose some challenges for Arduino people. Maybe @umbynos wants to take a look. I think the fix may not be too complicated but it does involve changing CMake files. Failed build log: |
I will close this one as dynamic link works for MinGW. For MSVC, it probably does not make sense to use dynamic link as of now. |
I have a PR ready for when the new version of avrdude comes out to drop the patch for the cmake and to use 65bb41f |
My main interest here is for Windows. How can I shared a version of avrdude binary which is dynamically linked to libusb-1.0.dll, libftdi1.dll and libhidapi.dll under Windows? I do not really need to build the shared library as it may take some time (at least for Windows, not an issue for Linux) as per #952, #953 and #954.
The text was updated successfully, but these errors were encountered: