Wireshark mailing list archives

Re: Compilation issue on Mac OS


From: ajay saxena <aileronajay () gmail com>
Date: Sat, 22 Apr 2017 20:19:05 -0400

Also clang documentation (https://clang.llvm.org/docs/UsersManual.html)
states

Building a relocatable precompiled header requires two additional
arguments. First, pass the --relocatable-pch flag to indicate that the
resulting PCH file should be relocatable. Second, pass -isysroot
/path/to/build, which makes all includes for your library relative to the
build directory. For example:

# clang -x c-header --relocatable-pch -isysroot /path/to/build
/path/to/build/mylib.h mylib.h.pch

When loading the relocatable PCH file, the various headers used in the PCH
file are found from the system header root. For example, mylib.h can be
found in /usr/include/mylib.h. If the headers are installed in some other
system root, the -isysroot option can be used provide a different system
root from which the headers will be based. For example, -isysroot
/Developer/SDKs/MacOSX10.4u.sdk will look for mylib.h in
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/mylib.h.

On Sat, Apr 22, 2017 at 8:14 PM, ajay saxena <aileronajay () gmail com> wrote:

Hi Guy,

So i was able to find what is causing the issue. It is the -isysroot
option.

The -sysroot option is also present when make tries to compile the c file
in wireshark. When i add this flag to compilation of my test file, my test
file fails to compile and clang stops searching in /usr/local/include

Ajays-MacBook-Pro:scripts ajasaxen$ cc -v -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/
MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk importtest.c

Apple LLVM version 8.1.0 (clang-802.0.42)

Target: x86_64-apple-darwin16.5.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin

 "/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple
x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name importtest.c
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu penryn -target-linker-version
278.4 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/
MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -fdebug-compilation-dir
/Users/ajasaxen/scripts -ferror-limit 19 -fmessage-length 163
-stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0
-fencode-extended-block-signature -fmax-type-align=16
-fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/c4/
55pxmrx11s720rx49cxb3brc0000gn/T/importtest-ce55a6.o -x c importtest.c

clang -cc1 version 8.1.0 (clang-802.0.42) default target
x86_64-apple-darwin16.5.0

ignoring nonexistent directory "/Applications/Xcode.app/
Contents/Developer/Platforms/MacOSX.platform/Developer/
SDKs/MacOSX10.12.sdk/usr/local/include"

ignoring nonexistent directory "/Applications/Xcode.app/
Contents/Developer/Platforms/MacOSX.platform/Developer/
SDKs/MacOSX10.12.sdk/Library/Frameworks"

#include "..." search starts here:

#include <...> search starts here:

 /Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/include

 /Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/include

 /Applications/Xcode.app/Contents/Developer/Platforms/
MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include

 /Applications/Xcode.app/Contents/Developer/Platforms/
MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks
(framework directory)

End of search list.

*importtest.c:1:10: **fatal error: **'gcrypt.h' file not found*

#include <gcrypt.h>

*         ^*

1 error generated.


If i remove this option, the compilation succeeds for my test file. I
think if we are able to avoid this option, the make for wireshark will work
too.

Thanks,
Ajay

On Sat, Apr 22, 2017 at 4:47 PM, ajay saxena <aileronajay () gmail com>
wrote:

In the Makefile of epan/dissectors, I modified the AM_CPPFLAGS to add -v
flag and removed the /usr/local/include that I had earlier added as hack to
get the pack-ip.c to compile. Below is the verbose output from the compile

make[6]: Nothing to be done for `all'.

  CC       packet-ip.lo

Apple LLVM version 8.1.0 (clang-802.0.42)

Target: x86_64-apple-darwin16.5.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Conten
ts/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

 "/Applications/Xcode.app/Contents/Developer/Toolchains/Xcod
eDefault.xctoolchain/usr/bin/clang" -cc1 -triple
x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name packet-ip.c
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu penryn -target-linker-version
278.4 -v -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4
-debugger-tuning=lldb -coverage-file /Users/ajasaxen/gitHubProjects
/wireshark-official/wireshark/epan/dissectors/.libs/packet-ip.o
-resource-dir /Applications/Xcode.app/Conten
ts/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0
-dependency-file .deps/packet-ip.Tpo -sys-header-deps -MP -MT packet-ip.lo
-isystem /usr/local/Cellar/glib/2.50.3/include/glib-2.0 -isystem
/usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include -isystem
/usr/local/opt/gettext/include -isystem /usr/local/Cellar/pcre/8.39/include
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
platform/Developer/SDKs/MacOSX10.12.sdk -D HAVE_CONFIG_H -I . -I ../..
-I ../.. -I ../../epan -D _FORTIFY_SOURCE=2 -D G_DISABLE_SINGLE_INCLUDES -D
G_DISABLE_DEPRECATED -D _REENTRANT -I /usr/local/Cellar/gnutls/3.5.8/include
-I /usr/local/Cellar/nettle/3.3/include -I /usr/local/Cellar/libtasn1/4.10/include
-I /usr/local/Cellar/p11-kit/0.23.3/include/p11-kit-1 -I
/usr/local/opt/libgcrypt/include -I /usr/local/opt/libgpg-error/include
-I /usr/include/libxml2 -D PIC -O2 -Werror -Wall -Wextra -Wendif-labels
-Wpointer-arith -Wformat-security -Wvla -Waddress -Wattributes
-Wdiv-by-zero -Wignored-qualifiers -Wpragmas -Wno-overlength-strings
-Wno-long-long -Wheader-guard -Wc++-compat -Wunused-const-variable -Wshadow
-Wno-pointer-sign -Wold-style-definition -Wstrict-prototypes
-Wshorten-64-to-32 -Werror=implicit -fdebug-compilation-dir
/Users/ajasaxen/gitHubProjects/wireshark-official/wireshark/epan/dissectors
-ferror-limit 19 -fmessage-length 163 -fvisibility hidden -fwrapv
-stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0
-fencode-extended-block-signature -fmax-type-align=16 -fno-common
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops
-vectorize-slp -o .libs/packet-ip.o -x c packet-ip.c

clang -cc1 version 8.1.0 (clang-802.0.42) default target
x86_64-apple-darwin16.5.0

ignoring nonexistent directory "/Applications/Xcode.app/Conte
nts/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.12.sdk/usr/local/include"

ignoring nonexistent directory "/Applications/Xcode.app/Conte
nts/Developer/Platforms/MacOSX.platform/Developer/SDKs/
MacOSX10.12.sdk/Library/Frameworks"

ignoring duplicate directory "../.."

#include "..." search starts here:

#include <...> search starts here:

 .

 ../..

 ../../epan

 /usr/local/Cellar/gnutls/3.5.8/include

 /usr/local/Cellar/nettle/3.3/include

 /usr/local/Cellar/libtasn1/4.10/include

 /usr/local/Cellar/p11-kit/0.23.3/include/p11-kit-1

 /usr/local/opt/libgcrypt/include

 /usr/local/opt/libgpg-error/include

 /usr/include/libxml2

 /usr/local/Cellar/glib/2.50.3/include/glib-2.0

 /usr/local/Cellar/glib/2.50.3/lib/glib-2.0/include

 /usr/local/opt/gettext/include

 /usr/local/Cellar/pcre/8.39/include

 /Applications/Xcode.app/Contents/Developer/Toolchains/Xcode
Default.xctoolchain/usr/bin/../lib/clang/8.1.0/include

 /Applications/Xcode.app/Contents/Developer/Toolchains/Xcode
Default.xctoolchain/usr/include

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX
.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX
.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks
(framework directory)

End of search list.

*packet-ip.c:63:10: **fatal error: **'GeoIP.h' file not found*

#include <GeoIP.h>

*         ^*

1 error generated.

make[6]: *** [packet-ip.lo] Error 1

make[5]: *** [all-recursive] Error 1

make[4]: *** [all] Error 2

make[3]: *** [all-recursive] Error 1

make[2]: *** [all] Error 2

make[1]: *** [all-recursive] Error 1

make: *** [all] Error 2


On Sat, Apr 22, 2017 at 3:51 PM, Guy Harris <guy () alum mit edu> wrote:

On Apr 21, 2017, at 8:50 PM, ajay saxena <aileronajay () gmail com> wrote:

Here is the verbose output from that compile

Ajays-MacBook-Pro:scripts ajasaxen$ gcc -v importtest.c -o importtest
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Conten
ts/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/Xcode
Default.xctoolchain/usr/bin/clang" -cc1 -triple
x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name importtest.c
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu penryn -target-linker-version
278.4 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeD
efault.xctoolchain/usr/bin/../lib/clang/8.1.0 -fdebug-compilation-dir
/Users/ajasaxen/scripts -ferror-limit 19 -fmessage-length 169
-stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0
-fencode-extended-block-signature -fmax-type-align=16
-fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/c4/55pxmrx11s720rx49cxb3brc0000gn/T/importtest-8e4727.o -x
c importtest.c
clang -cc1 version 8.1.0 (clang-802.0.42) default target
x86_64-apple-darwin16.5.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeD
efault.xctoolchain/usr/bin/../lib/clang/8.1.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeD
efault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/Xcode
Default.xctoolchain/usr/bin/ld" -demangle -lto_library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeD
efault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch
x86_64 -macosx_version_min 10.12.0 -o importtest
/var/folders/c4/55pxmrx11s720rx49cxb3brc0000gn/T/importtest-8e4727.o
-lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeD
efault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/lib
clang_rt.osx.a

and in this compile /usr/local/include was searched. Whereas when it
compiles wireshark, it does not search in /usr/local/include.

Try modifying epan/dissectors/Makefile to pass the -v flag to gcc, and
then touch epan/dissectors/packet-ip.c and run a make, so we can see the
gcc -v output when trying to compile it.
____________________________________________________________
_______________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscr
ibe




___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: