presidentbeef / brat

Brat is a little language for people who don't like to be told what to do.
https://www.brat-lang.info/
93 stars 6 forks source link

Building on Mac osX #27

Closed andrewnc closed 4 years ago

andrewnc commented 4 years ago

I've tried for several hours to build on macOSx Mojave 10.14.5

I have fixed a few problems building Lua, but the build fails with

env MACOSX_DEPLOYMENT_TARGET=10.3 gcc -bundle -undefined dynamic_lookup -o md5.so lmd5.o -lcrypto
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [md5.so] Error 1

While Building Oniguruma is being executed.

I added make MACOSX_DEPLOYMENT_TARGET=10.6 DEFAULT_CC=clang -j8 PREFIX=$BRATPATH/bin/lua to line 41 in the build file which helped a few errors.

I currently have ./configure && CFLAGS="-I/usr/local/Cellar/openssl/1.0.2k/include /usr/local/Cellar//openssl/1.0.2s/lib" make MACOSX_DEPLOYMENT_TARGET=10.6 DEFAULT_CC=clang -j8 on line 50 with no success.

Any pointers? I love Brat and would enjoy using it on my Mac, and hopefully contributing more.

presidentbeef commented 4 years ago

Hi Andrew!

I have also had problems building on OSX. It sounds like you have made it farther than me, actually.

I will take a look in the morning and see what I can figure out.

presidentbeef commented 4 years ago

Thanks to your hints above I have it building on my machine, which is running OSX 10.14.6.

Try the update_osx_build branch and see if it works for you.

andrewnc commented 4 years ago

Hey! That's awesome the changes look great. I'm glad you got it working.

I checked out that branch and it got much further in the build than anything I tried. However, it still errors out

- stdlib/parser/ast.brat
lua: ...s/andrewcarr/Documents/workspace/eso_langs/brat/bin/brat:13: module 'lfs' not found:

I have tried installing luafilesystem via luarocks and that didn't seem to fix the problem. Any ideas?

thanks btw for the help, I'm really excited about Brat.

presidentbeef commented 4 years ago

Hm... If it made it that far, LFS should have been built correctly.

Seems like a path issue. Do you have lib/lfs.so in your Brat directory?

Brat has all its direct dependencies in the repo, including LuaJIT, etc. It's possible external Lua stuff or path variables might be confusing things.

andrewnc commented 4 years ago

Yup! That file is in my Brat directory.

Sorry for closing, I misclicked..

I will try recloning the repo

andrewnc commented 4 years ago

I recloned, and that didn't seem to help. I'm not sure what else to try. Is there a way to reset lua related paths?

Do we need an lfs.dylib for macOS?

presidentbeef commented 4 years ago

lib/lfs.so should work fine, since it is for me.

You could try adding print(package.cpath) prior to require("lfs") in bin/brat to see what the load path is. You should see something at the end like <your brat path>/brat/lib/?.so.

At the point in the build where it's failing for you, Brat is essentially built, just with an older "compiler". So you should be able to run ./brat yourself for testing.

presidentbeef commented 4 years ago

You could try modifying the paths to limit them in brat like this:

export LD_LIBRARY_PATH=$path/lib
export DYLD_LIBRARY_PATH=$path/lib
export PATH=$path/bin/lua/bin

I mean...it shouldn't matter but maybe?

andrewnc commented 4 years ago

Thanks again for all your help. I blog about esoteric languages for data science and want to write about Brat.

Anyway, my path is ./?.so;/usr/local/lib/lua/5.1/?.so;/Users/andrewcarr/Documents/workspace/eso_langs/brat/bin/lua/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;...s/andrewcarr/Documents/workspace/eso_langs/brat/lib/?.so

I can't just run ./brat unfortunately.

I also tried exporting in brat but with no success.

presidentbeef commented 4 years ago

Waiiit a second.

It's literally ...s/andrewcarr/Documents/workspace/eso_langs/brat/lib/?.so ? What happened to /User? I saw that earlier but thought it was being truncated or you were redacting it.

Something is going wrong with adding that path. It could be in the ./brat script file or in bin/brat.

You can try hardcoding the path in either/both:

export DYLD_LIBRARY_PATH=/Users/andrewcarr/Documents/workspace/eso_langs/brat/lib/
package.cpath = package.cpath .. ";" .. "/Users/andrewcarr/Documents/workspace/eso_langs/brat/lib/?.so"
andrewnc commented 4 years ago

We literally just figured that out!! Excellent. Hard coding the program_path is what did it for us.

presidentbeef commented 4 years ago

Okay!

It appears short_src truncates the source location. Your directory was just too deep :smile:

Please try the updated update_osx_build.

andrewnc commented 4 years ago

That was it, the new build branch works like a charm

presidentbeef commented 4 years ago

Great! Thank you for reporting and working through this with me!