# Building mapnik V3 and node-mapnik with clang?



## PeterSprague (Feb 21, 2015)

I need to build Mapnik V3 and node-mapnik V3 for Tilemill.

Has anyone gotten this to build on their 10.1 systems?  Currently trying to build on a PCBSD 10.1 system, but fails.

Github issues reports: https://github.com/mapnik/mapnik-support/issues/33 with error log gists.

Seems to be a FreeBSD clang and clang++ issue according to the developer.

make.conf:

```
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CPP=/usr/bin/clang-cpp
```

Solution is completely eluding me.  Has to be something simple I am missing.

Thanks.


----------



## acheron (Feb 22, 2015)

`/usr/bin/ld: can't find -ldl`: ldl is a linuxism and must be removed on FreeBSD


----------



## PeterSprague (Mar 15, 2015)

Removed from where? SConstruct?

`git pull`
`git branch` -> master aka V3

Ran: (as per: https://github.com/mapnik/mapnik/wiki/UsingScons)
`python scons/scons.py configure CXX=clang++ CC=clang ICU_LIB=/usr/local/lib ICU_INCLUDES=/usr/local/include`
compiles successfully -> requests to use make and make install
`python scons/scons.py`

Same error as above: 
	
	



```
/usr/bin/ld: can't find -ldl
```

See: https://forums.freebsd.org/threads/usr-bin-ld-cannot-find-ldl.5799/


----------



## acheron (Mar 16, 2015)

Use `grep -r ldl /path/to/mapnik_src` to find where ldl is passed to LDFLAGS.


----------



## PeterSprague (Mar 25, 2015)

`cd mapnik
grep -r ldl ./`

yields:

```
./include/mapnik/css_color_grammar.hpp: ("oldlace", color(253, 245, 230))
./.mason/README.md:-L/Users/user/mason_packages/osx-10.10/libuv/0.11.29/lib -luv -lpthread -ldl
./utils/mapnik-config/mapnik-config:CONFIG_DEP_LIBS=' -lboost_filesystem -lboost_regex -lcairo -lpng -lproj -ltiff -lwebp -lxml2 -licui18n -lboost_system -lharfbuzz -ljpeg -licuuc -lfreetype -lz -ldl'
Binary file ./scons/scons-local-2.3.4/SCons/Node/Alias.pyc matches
grep: ./src/libmapnik.so.3.0: No such file or directory
```

`mapnik-config --dep-libs`
yields:

```
-lfreetype -lz -licuuc -lboost_filesystem -lboost_system -lboost_regex -lproj -lpng -ljpeg -ltiff -lxml2 -lboost_thread -licui18n -lcairo
```
aka no -ldl

`python scons/scons.py configure ICU_LIB=/usr/local/lib ICU_INCLUDES=/usr/local/include HARFBUZZ_LIlocal/lib HARFBUZZ_INCLUDES=/usr/local/include`

`vi /utils/mapnik-config/mapnik-config`
go to line: CONFIG_DEP_LIBS="
delete -ldl
`python scons/scons.py`

error and `make` exits:

```
------------------------------
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o src/libmapnik.so -Wl,-rpath-link,. -Wl,-soname,libmapnik.so.3.0 -Wl,-rpath=/usr/local/lib -shared src/expression_grammar.os src/fs.os src/request.os src/well_known_srs.os src/params.os src/image_filter_types.os src/miniz_png.os src/color.os src/conversions.os src/image_copy.os src/image_compositing.os src/image_scaling.os src/box2d.os
~~~~~~~~
-Lsrc/wkt -L/usr/local/lib -L/usr/lib -lagg -lboost_filesystem -lboost_regex -lcairo -lpng -lproj -ltiff -lwebp -lxml2 -licui18n -lboost_system -lharfbuzz -ljpeg -licuuc -lfreetype -lz -ldl
/usr/bin/ld: cannot find -ldl
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [src/libmapnik.so] Error 1
scons: building terminated because of errors.
----------------------------------------------------
```

./utils/mapnik-config/mapnik-config is rewritten to include -ldl
`mapnik-config --dep-libs`
yields:

```
-lfreetype -lz -licuuc -lboost_filesystem -lboost_system -lboost_regex -lproj -lpng -ljpeg -ltiff -lxml2 -lboost_thread -licui18n -lcairo
```
aka no -ldl

How to rewrite the dependency libs to not include -ldl on `make`?


----------



## PeterSprague (Mar 26, 2015)

See: https://github.com/mapnik/mapnik-support/issues/33


----------

