Closed darioizzo closed 7 years ago
There's no reason you couldn't do it that way. I do agree it is nicer to have just one library.
There are a few reasons why I do it this way though. Most of the reasons are influenced by the precompiled libraries that we offer on our website.
There are a few third-party projects that use SNOPT, but that haven't been updated to use the latest C/C++/other-language interface. A majority of our trial downloads are from students who are using SNOPT with these projects. If I combined the interface with the Fortran library, they wouldn't be able to use them. Right now, if someone needs a different version of an interface, they can compile it themselves and link it. Similarly, there are a few third-party projects that have their own C/C++ interface to SNOPT. If I don't separate Fortran and the C/C++ library, it might break these.
During early development of the non-Fortran interfaces, there were a lot of changes and issues (compared with the actual Fortran SNOPT library which doesn't change much at all). It was easier to keep them separate so that anyone who already had the Fortran library could just grab the code off github and update the interface libraries. Since the interfaces were developed relatively recenty, this also allowed people who had older versions of SNOPT to use the interface.
I did actually try combining libraries initially but opted for the current situation. Some things have changed now so perhaps I will think about it again.
Thanks. For the time being, in our SNOPT7 plugin for pagmo (https://esa.github.io/pagmo2/), I ask users to recompile the snopt7_c library and link it to the fortran one, e.g. using "LDFLAGS = -avoid-version -lsnopt7" in the Makefile. (this makes my plugin based on dlopen work elegantly and not be forced to load all fortran symbols explicitly from a different library)
If you select this as a default behaviour, I would be very happy :) and simplify the instructions for our users.
I just realized that I misunderstood what you were asking for.
Just to be sure I've created a branch with what I think you've asked for issue/8. In particular, the Makefile was modified to so that the C/C++ library links to the specified Fortran SNOPT library, and the included examples only link to snopt_c or snopt_cpp.
Makefile diff: https://github.com/snopt/snopt-interface/commit/0331b091020b4fb4e8804396533f61fa85496991#diff-7e056ddc530791272d363e50c1f25647
Indeed thats is great! If merged, I can now dlopen the library snopt_c and have the fortran symbols resolved too, thanks!
Is there a good reason for not having the snopt7 library linked to the snopt7_c / snopt_cpp libraries?
There are very good reasons to have it so.
I understand that as it is now, the libraries snopt7_c and snopt7_cpp, can be generated also without access to the fortran library, but I do not see the advantage of that.
One option could also be to try and detect the snopt7 fortran library and, if successful, link it in, otherwise leave things as are.