osxpeppermint / peppermint

The official bug/features tracker for Peppermint
8 stars 2 forks source link

Cannot run Objective-C code #45

Closed iabudiab closed 9 years ago

iabudiab commented 9 years ago

Objective-C code fails to run with the following error:

ld: warning: ignoring file ../Library/Application Support/Peppermint/Data/Temp/9547.tmp, file was built for unsupported file format ( 0x2F 0x2A 0x2A 0
x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A 0x2A ) which is not the architecture being linked (x86_64): /Users/iska/Library/Application Support/
Peppermint/Data/Temp/9547.tmp

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

bash: ../Library/Application Support/Peppermint/Data/Temp/a.out: No such file or directory

I thought it may be sandboxing-related, but this also happens with the latest trial version downloaded directly from the site

osxpeppermint commented 9 years ago

Well, I initially thought it would be an AppStore-related error, as well - but given that you've tried with the trial as well, I really don't know.

First of all, just send me an e-mail I will send you a valid License, so that we are working on the same basis.

If this doesn't work (and it has to do with the compilation process), we'll see about that...

For your information, here's how Objective-C code compilation is currently being handled (the actual Run plugin for Objective-C, in CoffeeScript - I believe it's rather self-explanatory):

https://github.com/osxpeppermint/peppermint-spec-plugins/blob/master/Objective-C/Run.ppPlugin/script.coffee

iabudiab commented 9 years ago

Thanks for pointing out the Script that runs the Objective-C code. The file extension is the culprit. Try compiling a source file with a .tmp extension directly with clang in the shell and you'll get the Undefined symbols for architecture x86_64: "_main"

If I'm not mistaken, any extension not recognised as a source code is passed to the linker as an object file.

PS: I've got Peppermint via the Creatable bundle, does it also have the sandboxing restriction?

iabudiab commented 9 years ago

Update: Saving the file with a correct extension then running it works.

Same behaviour can be seen for C and C++ snippets when run without saving first. The temp files under the Application Support/Peppermint/Data/Temp/ directory must be renamed, either automatically or via a dialog asking the user something like: "Run as C, C++ or ObjC?" in order to assign the correct extension.

osxpeppermint commented 9 years ago

The issue has been fixed and will be published as part of the upcoming 1.5 beta6 (and in the final 1.5 release).