[cairo] [MSVC] Link Error when building Static Libraries using Meson
Naveen M K
naveen at syrusdark.website
Tue Feb 23 10:00:02 UTC 2021
Hi,
I tried building Cairo statically on MSVC 2019. I got some link errors.
What I did was get Cairo source from https://gitlab.freedesktop.org/cairo/cairo/-/archive/1.17.4/cairo-1.17.4.tar.gz
and then configure using this command
meson setup cairobuild_dir --default-library=static -Dtee=enabled -Dglib=disabled -Dfreetype=enabled -Dfontconfig=disabled -Dzlib=enabled -Dtests=disabled --buildtype=release --prefix="C:\cairo_build\prefix"
I got a link error when running `meson compile -C cairobuild_dir`
```
[354/366] Linking target util/cairo-script/csi-replay.exe
FAILED: util/cairo-script/csi-replay.exe
"link" /MACHINE:x64 /OUT:util/cairo-script/csi-replay.exe util/cairo-script/csi
-replay.exe.p/csi-replay.c.obj "/nologo" "/release" "/nologo" "/OPT:REF" "src\li
bcairo.a" "subprojects\zlib-1.2.11\libz.a" "subprojects\libpng-1.6.37\libpng16.a
" "subprojects\freetype2\libfreetype.a" "subprojects\pixman\pixman\libpixman-1.a
" "util\cairo-script\libcairo-script-interpreter.a" "gdi32.lib" "msimg32.lib" "g
di32.lib" "msimg32.lib" "gdi32.lib" "msimg32.lib" "/SUBSYSTEM:CONSOLE" "kernel32
.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut3
2.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib"
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_create
referenced in function _context_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_destroy
referenced in function _context_destroy
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_set_sou
rce_surface referenced in function _context_destroy
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_paint r
eferenced in function _context_destroy
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_surface
_create_similar referenced in function _similar_surface_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_surface
_reference referenced in function _context_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_surface
_destroy referenced in function _context_destroy
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_surface
_status referenced in function _context_destroy
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_image_s
urface_create referenced in function _image_surface_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_
interpreter_create referenced in function main
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_
interpreter_install_hooks referenced in function main
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_
interpreter_run referenced in function main
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_
interpreter_destroy referenced in function main
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_pdf_sur
face_create_for_stream referenced in function _pdf_surface_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_ps_surf
ace_create_for_stream referenced in function _ps_surface_create
csi-replay.c.obj : error LNK2019: unresolved external symbol __imp_cairo_svg_sur
face_create_for_stream referenced in function _svg_surface_create
util\cairo-script\csi-replay.exe : fatal error LNK1120: 16 unresolved externals
```
and
```
[356/366] Linking target util/cairo-script/csi-exec.exe
FAILED: util/cairo-script/csi-exec.exe
"link" /MACHINE:x64 /OUT:util/cairo-script/csi-exec.exe util/cairo-script/csi-e
xec.exe.p/csi-exec.c.obj "/nologo" "/release" "/nologo" "/OPT:REF" "src\libcairo
.a" "subprojects\zlib-1.2.11\libz.a" "subprojects\libpng-1.6.37\libpng16.a" "sub
projects\freetype2\libfreetype.a" "subprojects\pixman\pixman\libpixman-1.a" "uti
l\cairo-script\libcairo-script-interpreter.a" "gdi32.lib" "msimg32.lib" "gdi32.l
ib" "msimg32.lib" "gdi32.lib" "msimg32.lib" "/SUBSYSTEM:CONSOLE" "kernel32.lib"
"user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "comdlg32.lib" "advapi32.lib"
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_image_sur
face_create referenced in function _surface_create
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_in
terpreter_create referenced in function main
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_in
terpreter_install_hooks referenced in function main
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_in
terpreter_run referenced in function main
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_in
terpreter_get_line_number referenced in function main
csi-exec.c.obj : error LNK2019: unresolved external symbol __imp_cairo_script_in
terpreter_destroy referenced in function main
util\cairo-script\csi-exec.exe : fatal error LNK1120: 6 unresolved externals
```
I didn't have anything pre-installed, every dependency was built using the fallback
subprojects by meson.
Thanks for the help in advance.
--
Naveen
More information about the cairo
mailing list