mcfarljm / fortwrap

MIT License
27 stars 8 forks source link

Awesome project! (But undefined symbols for architecture arm64) #2

Open vegardjervell opened 1 year ago

vegardjervell commented 1 year ago

First of all I want to say that this project looks awesome! I am currently looking at options for refactoring and making a robust wrapper for a quite large Fortran project, and this looks like exactly what I need!

I noticed this repo has been quiet for a while, and was also kind of wondering why? Have better options come up or is it just one of those things that has gone quiet after a while?

Finally (i needed an excuse to post an issue): When running run_tests.py I get some failed builds, running gfortran 12.2.0 on MacBook Pro with M1 Pro (arm64) chip. Specifically:

5 error(s): [('strings', 'build'), ('complex', 'build'), ('arrays', 'build'), ('pointers', 'build'), ('matrices', 'build')]

They all result from similar Undefined symbols for architecture arm64: errors, respectively:

I also got some linker warnings that I'm currently looking more closely at. However (and more importantly for what I need) the classes seem to run as expected. I'll let you know if I move forward with this and find a fix.

mcfarljm commented 1 year ago

Hi, thanks for your interest. I haven't been actively working on this repo in quite a while because I am no longer involved in the project that needed this wrapping approach. I'm not particularly up to date on what all alternatives are out there these days, but this was kind of a niche solution when it was originally developed, and I wasn't aware of other work taking this same approach.

I'm open to helping address minor issues, but I probably won't have time for significant developments/enhancements.

Based on your errors, I don't think this is a wrapping issue. My first guess is it may be an incompatibility between the C++ compiler that is compiled the C++ object code vs the libstdc++ that it is linking to. The tests use a Makefile that uses Fortran as the linker language, and it links against libstdc++:

https://github.com/mcfarljm/fortwrap/blob/e82840a2b8d105cc3655da33dbf4b2073fa462d8/tests/Tests.mk#L13-L14

I'm not super-familiar with Macs, but my understanding is the default C/C++ toolchains use Clang. If you do g++ --version on a default install, I think it will indicate Clang. I'm not sure if you also have GNU g++ installed, but maybe there's a mismatch between the C++ compiler and the libstdc++ that is being linked? If you have a working mixed-language compilation Makefile/command, you might check that and see if you can adapt the compilation/linking commands in the FortWrap test Makefile.

Another thought is you might try the iso_c_binding branch and see if that changes anything. That uses a more portable wrapping approach. I don't think that will fix your issue, though, since I think your errors are not originating from the wrapping code, but it's worth a try.

vegardjervell commented 1 year ago

Thanks for your quick reply! What you outline seems reasonable, I'll have a closer look at the makefiles and the iso_c_binding branch. If you don't really maintain this anymore I won't expect any updates, but I'll leave a PR if we move forward with this and make any further developments :)