How to compile using Clang?

I’m having a problem with compiling. I’ve never used clang and I’m not sure how set up environment etc…

In Linux, I just did export CC=clang and export CXX=clang++
and It works great.
I am not sure on MaC OS but feel that it should work as both are UNIXs

Doesn’t help, same error.

Hi Michael,

I'm having a problem with compiling. I've never used clang and I'm not sure
how set up environment etc...

(snip)

Trying to make:
make
Making all in backend

(snip libtool invoking clang)

In file included from deps/http-parser/http_parser.c:21:
deps/http-parser/http_parser.h:28:10: fatal error: 'sys/types.h' file not
found
#include <sys/types.h>
^
1 error generated.
make[1]: *** [libfiresheep_la-http_parser.lo] Error 1
make: *** [all-recursive] Error 1

***

cat /usr/include/sys/types.h - http://pastebin.com/ke59jmfq

***

clang --version
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

***

I have never been proficient in solving includes and compiling dependecies,
simple Google search search in this case neither... Probably this a matter
of setting one flag or another. Any hints?

First, run

make CXXFLAGS=-v

This will pass the -v flag to clang, causing it to print the
directories where headers are searched, among other things. Perhaps
this will help understand why the compiler doesn't find sys/types.h (I
suspect this option: -isysroot /Developer/SDKs/MacOSX10.6.sdk).

Csaba

That is actually very good hint :slight_smile:

Here is full output: http://pastebin.com/HhVEVLTG

Most important parts:

#include “…” search starts here:
#include <…> search starts here:
.
deps/
deps/http-parser
deps/json_spirit
/usr/bin/…/lib/clang/3.1/include
End of search list.
In file included from deps/http-parser/http_parser.c:21:
deps/http-parser/http_parser.h:28:10: fatal error: ‘sys/types.h’ file not found
#include <sys/types.h>

make CXXFLAGS=-v

This will pass the -v flag to clang, causing it to print the
directories where headers are searched, among other things. Perhaps
this will help understand why the compiler doesn't find sys/types.h (I
suspect this option: -isysroot /Developer/SDKs/MacOSX10.6.sdk).

That is actually very good hint :slight_smile:

Here is full output: http://pastebin.com/HhVEVLTG

Most important parts:
#include "..." search starts here:
#include <...> search starts here:
.
deps/
deps/http-parser
deps/json_spirit
/usr/bin/../lib/clang/3.1/include
End of search list.
In file included from deps/http-parser/http_parser.c:21:
deps/http-parser/http_parser.h:28:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>

***

https://www.google.com/search?q=makefile+include+path

I haven't used makefiles for a while - can you help me solving this "puzzle"? :slight_smile:

We can't without knowing what is installed on your machine.
You use the flags "-isysroot /Developer/SDKs/MacOSX10.6.sdk" to tell clang to lookup headers in "/Developer/SDKs/MacOSX10.6.sdk"
Bu we can't tell you if this folder exists, and what it contains.

Thanks
Michal
_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-- Jean-Daniel

Hi Michaelm

make CXXFLAGS=-v

This will pass the -v flag to clang, causing it to print the
directories where headers are searched, among other things. Perhaps
this will help understand why the compiler doesn't find sys/types.h (I
suspect this option: -isysroot /Developer/SDKs/MacOSX10.6.sdk).

That is actually very good hint :slight_smile:

Here is full output: http://pastebin.com/HhVEVLTG

Most important parts:

Actually, you omitted some important parts :slight_smile:

ignoring nonexistent directory
"/Developer/SDKs/MacOSX10.6.sdk/usr/local/include"
ignoring nonexistent directory "/Developer/SDKs/MacOSX10.6.sdk/usr/include"
ignoring nonexistent directory
"/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks"
ignoring nonexistent directory
"/Developer/SDKs/MacOSX10.6.sdk/Library/Frameworks"

#include "..." search starts here:
#include <...> search starts here:
.
deps/
deps/http-parser
deps/json_spirit
/usr/bin/../lib/clang/3.1/include
End of search list.
In file included from deps/http-parser/http_parser.c:21:
deps/http-parser/http_parser.h:28:10: fatal error: 'sys/types.h' file not
found
#include <sys/types.h>

I haven't used makefiles for a while - can you help me solving this
"puzzle"? :slight_smile:

Change the makefile to not pass the -isysroot
/Developer/SDKs/MacOSX10.6.sdk option to clang.
It's the CFLAGS line.

Alternatively, install the Mac OSX 10.6 SDK into /Developer/SDKs

Thank you for suggestions!

It actually helped someone else… And I’m still having same problems

ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.6.sdk MacOSX10.7.sdk

Essence:

In file included from deps/http-parser/http_parser.c:21:
deps/http-parser/http_parser.h:28:10: fatal error: ‘sys/types.h’ file not found

Full output: http://pastebin.com/fa2AGjrC

How to solve it?
Thanks
Michal

Just for future reference: the problem has been solved.

More details: https://github.com/codebutler/firesheep/issues/169#issuecomment-6985466

In brief:
changing CFLAGS in configure.ac
CFLAGS = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7

Works like a charm. I would say this a simple solution, something really simple I initially expected to be :]