gjtorikian / mathematical

Convert mathematical equations to SVGs, PNGs, or MathML. A general wrapper to Lasem and mtex2MML.
https://gjtorikian.github.io/mathematical/
MIT License
164 stars 31 forks source link

Failed to install on Fedora 24 due to strdup error in mtex2MML #64

Closed ProgramFan closed 8 years ago

ProgramFan commented 8 years ago

gem install mathematical-1.6.7 fails on Fedora 24 (with gcc 6.1) with the following error:

current directory: /home/zyang/.local/share/rvm/gems/ruby-2.3.0/gems/mathematical-1.6.7/ext/mathematical
make "DESTDIR="
compiling lasem_overrides.c
In file included from /usr/include/string.h:630:0,
                 from /home/zyang/.local/share/rvm/gems/ruby-2.3.0/gems/mathematical-1.6.7/ext/mathematical/mtex2MML/src/../deps/uthash/uthash.h:29,
                 from /home/zyang/.local/share/rvm/gems/ruby-2.3.0/gems/mathematical-1.6.7/ext/mathematical/mtex2MML/src/environment.h:4,
                 from /home/zyang/.local/share/rvm/gems/ruby-2.3.0/gems/mathematical-1.6.7/ext/mathematical/mtex2MML/src/mtex2MML.h:12,
                 from lasem_overrides.c:5:
/home/zyang/.local/share/rvm/gems/ruby-2.3.0/gems/mathematical-1.6.7/ext/mathematical/mtex2MML/src/../deps/uthash/../strdup/strdup.h:24:1: error: expected identifier or ‘(’ before ‘__extension__’
 strdup(const char *str);
 ^
lasem_overrides.c: In function ‘lsm_itex_to_mathml’:
lasem_overrides.c:23:1: warning: control reaches end of non-void function [-Wreturn-type]
 lsm_itex_to_mathml (const char *itex, gssize size) { }
 ^~~~~~~~~~~~~~~~~~
Makefile:238: recipe for target 'lasem_overrides.o' failed
make: *** [lasem_overrides.o] Error 1
ProgramFan commented 8 years ago

It seems the strdup override conflict with the real strdup in string.h. Commenting out the strdup declaration in mtex2MML/deps/strdup/strdup.h solves the problem.

gjtorikian commented 8 years ago

Could you try installing with the environment variable MATHEMATICAL_SKIP_STRDUP enabled, such as:

MATHEMATICAL_SKIP_STRDUP=1 gem install mathematical

This problem has begun recently and I confess I don't know what is causing it. I thought that the ifdef in mtex2mml would take care of conflicts with strdup but that does not seem to be the case. strdup is not part of the C standard so I felt the need to include it. Perhaps I ought to rename the file (string_dupe?) so that it does not conflict with existing implementations? Do you have any suggestions?

ProgramFan commented 8 years ago

MATHEMATICAL_SKIP_STRDUP=1 solves the problem perfectly. I have tried to comment out the strdup line and it broke mtex2MML compilation (although the aforementioned file compiled). The CMakeLists.txt of mtex2MML also lacks proper support to detect HAVE_STRDUP. If strdup is only used internally by mtex2MML, I would suggest rename it.

gjtorikian commented 8 years ago

The CMakeLists.txt of mtex2MML also lacks proper support to detect HAVE_STRDUP

I'm not sure what you mean by this but if you know of a fix, I would very much appreciate a pull request! https://github.com/gjtorikian/mtex2MML

I'll close this out for now since the original issue is solved and, pending an update to the CMakeLists file, I may just rename method to avoid conflict.

akosma commented 6 years ago

This fix does not work in macOS Mojave 10.14, and the gem cannot be installed.

aronayne commented 5 years ago

Can also confirm this fix does not work in macOS Mojave 10.14.