Skip to content
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

Compiling TRMorph on Mac OSX gives error #9

Closed
eakarsu opened this issue Nov 26, 2014 · 5 comments
Closed

Compiling TRMorph on Mac OSX gives error #9

eakarsu opened this issue Nov 26, 2014 · 5 comments

Comments

@eakarsu
Copy link

eakarsu commented Nov 26, 2014

I compiled foma successfully and having issues with TRMorph on Mac.

I try to compile TRMorh on Mac OSX but getting problem. Can you help me?

orph.lexc:892:22: error: invalid preprocessing directive
#;
^
morph.lexc:947:22: error: invalid preprocessing directive
#;
^
morph.lexc:982:18: error: invalid preprocessing directive
#;
^
morph.lexc:995:18: error: invalid preprocessing directive

@coltekin
Copy link
Owner

It seems to be a known issue with the Clang on MacOS. Using standard gcc preprocessor seems to be the easier solution. There are some discussion of how to solve the exact same issue here.

If installing/using standard gcc is not an option, please let me know. It should be posible to change the source to make sure it also compiles with Clang preprocessor.

@evanmiltenburg
Copy link

I also had issues on my mac, but I just compiled the fst file on a Linux computer and I can just use the fst file with foma on my mac. Maybe it's possible to have an "official" compiled fst file in this repository?

@keryil
Copy link

keryil commented Jul 2, 2017

I am writing this for future reference for people running into this issue, in case Cagri doesn't have time to fix this one. The workaround is quite simple, and only depends on Homebrew. People often use Homebrew to install foma on OS/X anyway.

The way I work around this issue is:

  1. Install GCC (through Homebrew i.e. brew install gcc).
  2. Discover the GCC binary. It is not /usr/bin/gcc, which is an alias for clang compiler on OS/X. It is often something along the lines of gcc-4.9 (depending on the version, of course). Confirm you got the right one by issuing the command gcc-4.9 -v. The output should tell you the details of the compiler. Look for words clang and homebrew to distinguish between the two, and make sure you get the one that contains homebrew.
  3. Modify the Makefile of the project (i.e. the file called Makefile in the TRmorph root). Find the lines that start with CPP=gcc... and MAKEDEP=gcc..., and replace gcc with the GCC binary you located in the previous step e.g. gcc-4.9.
  4. Make.

Hope this helps.

@snomos
Copy link
Contributor

snomos commented Sep 3, 2018

Installing & using GCC is not an option for me. Could a solution be to replace all #'s with a reference to a new lexicon ENDLEX, and then define that lexicon as follows?

LEXICON ENDLEX # ;

That should hopefully resolve the issue, by "protecting" the hash mark using the preceding text.

@snomos
Copy link
Contributor

snomos commented Sep 3, 2018

That pull request only solves the issue with #. Now I have a number of the following errors:

In file included from analyzer.lexc:43:
./lexicon/punctuation:8:17: error: invalid preprocessing directive
%:              Punc;
                ^
In file included from analyzer.lexc:51:
./lexicon/emoticon:37:4: error: invalid preprocessing directive
 %:-)           Interjection;
   ^
...

The problem seems to be the sequence %:. And in this case it is not easy to see how to change the code to make it pass the macOS C++ preprocessor, not without seriously garbling the lexc code. Suggestions welcome :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants