Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GCC/Clang's -framework option work on Linux?

On OSX's development environment there is the concept of frameworks. A framework is a kind of bundle which contains headers, shared libraries and other useful stuff. A framework can be passed to the compiler, so that the compiler includes its headers on the search path and uses its shared libraries to link programs against them.

So, for example, if -framework FrameworkName is passed to gcc or clang on OSX, the compiler looks up the /System/Library/Frameworks directory to find the FrameworkName.framework dir. If it is found, the compiler includes its headers and links the program against its shared libraries.

So, does this super useful feature work on Linux? Do gcc or clang recognize the -framework option on Linux? When I type this option on Linux, the compiler seems not to recognize it, but maybe this is because I need to set the frameworks directory path before it. Is there any special trick to make it work on Linux? Or that is definitely impossible on this platform?

like image 451
LuisABOL Avatar asked Mar 09 '13 13:03

LuisABOL


2 Answers

No, it won't work on Linux. Frameworks are a feature of the (OS X) Mach-O ABI. In theory, you could write a kernel module for Mach-O support, and supply linker / loader userspace tools. It would be a lot of work.

like image 182
Brett Hale Avatar answered Sep 20 '22 02:09

Brett Hale


I use it on FreeBSD so yes framework should work on Linux. A framework is just a self contain folder for header, resources and lib file. The lib can have ELF format and you do not need mach-o support.

So it depend on what you want to do.

  • If you wish to use Cocoa framework then you most probably will not have it on linux. But if you are looking for object in the Foundation framework you can have it by installing GNUStep.

  • If you wish to build your own Framework that is possible too. In GNUStep you will find some helper makefile for that.

like image 31
mathk Avatar answered Sep 21 '22 02:09

mathk