-
Notifications
You must be signed in to change notification settings - Fork 260
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
[WINDOWS] Cannot create a working import library. #874
Comments
Here there are the logs taken from the configuration and the build processes. |
Having different name is the right solution, because for each build each generated
We should pay attention to keep the dependency relationship. fluidsynth executable is dependent of libfluidsynth. |
Normally the decision to enable/disable the generation of import library should be under developer control. As MinGW is chosen by the developer via CMake, we should have the way to instruct CMake to enable/disable import library generation. |
The import lib should not be created for the fluidsynth executable. Unfortunately, I have no idea, where this comes from. Technically, this particular case should be controllable with the CMAKE_ENABLE_EXPORTS variable. I tried setting it to I had a look into the |
The only way that I found for fixing the problem is:
Do you think that it could be a (last resource) solution? EDIT: if you look into
In other words, the |
Thanks for the hint. This made me find this issue: https://gitlab.kitware.com/cmake/cmake/-/issues/19805 I don't quite know where this |
__declspec(dllexport) are specified as decoration in any API name in fluidsynth library source. It seems that the source directory organisation for any target (.ddl or .exe) instructs cmake on how to trigger the import lib creation. |
In the library, i.e. libfluidsynth, yes. But I was talking about the executable.
Not according to Brad King's comment in the linked cmake issue. |
I tried your patch: changing the prefix of output file name for the import library has also fixed the problem with CYGWIN, MinGW-w64 and MSys2. NOTE: When I tried MinGW-w64, at the beginning CMake was failing because a different error:
After I forced |
Hm, cmake is supposed to populate the |
That patch fixed also this issue. Thank you. |
The recent change is #871 and here CMake never failed (choosing MSVC generator). |
Probably not: that thing happened also if you try to cross compile FluidSynth. I suspect that I discovered it for pure case because I called MinGW-w64 from the bash of CYGWIN. |
I discovered that when you compile FluidSynth for Windows with MinGW or CYGWIN or MinGW-w64, it does not create a working import library. Or better: it creates it but later it can be overwritten by another file with the same name.
Let's take a look to the link command for libfluidsynth-3.dll:
/usr/bin/x86_64-w64-mingw32-g++.exe -Wall -W -Wpointer-arith -Wcast-qual -Wno-unused-parameter -Wcast-align -fopenmp -O2 -g -DNDEBUG -Wl,--no-undefined -shared -o libfluidsynth-3.dll -Wl,--out-implib,libfluidsynth.dll.a -Wl,--major-image-version,3,--minor-image-version,0 -Wl,--whole-archive CMakeFiles/libfluidsynth.dir/objects.a -Wl,--no-whole-archive @CMakeFiles/libfluidsynth.dir/linklibs.rsp
The option
-Wl,--out-implib,libfluidsynth.dll.a
instructs the compiler to create an import library called libfluidsynth.dll.a that you can use for linking a program to libfluidsynth-3.dll.Later, the build process compiles the fluidsynth.exe test application:
/usr/bin/x86_64-w64-mingw32-gcc.exe -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Wbad-function-cast -Wcast-align -fopenmp -O2 -g -DNDEBUG -Wl,--as-needed -Wl,--whole-archive CMakeFiles/fluidsynth.dir/objects.a -Wl,--no-whole-archive -o fluidsynth.exe -Wl,--out-implib,libfluidsynth.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/fluidsynth.dir/linklibs.rsp
and if you look this command, you will see again
-Wl,--out-implib,libfluidsynth.dll.a,
identical to the previous one but generated from the test application!In conclusion this is what happens:
It was not immediate to see this issue because the build process does not fail.
Basically, this happens because "fluidsynth" is the base name for both the library and the test application. I tried to search around the net but I was not able to find a way to disable this -Wl,--out-implib option for the test application. Perhaps, in this case the only solution is to put fluidsynth.c in a separate directory with its own CMakeLists.txt file, so that it won't conflict anymore with the library.
MinGW, CYGWIN and MinGW-w64 alway show this defect.
With MSYS2, it seems there is something different: most of the times it is working fine, but sometime it does not. Perhaps it is luck, and it may depend on some locks and on which resource of the filesystem is unlocked first, I don't know.
The text was updated successfully, but these errors were encountered: