#zig build fails on a C++ project.

1 messages · Page 1 of 1 (latest)

normal yew
#

I'm trying to move away from using a makefile to build a toy c++ project I have, I have written a corresponding build.zig file but when I try to run zig build it fails with the following log

error: ld.lld: undefined symbol: YAML::LoadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
    note: referenced by config.cpp:53 (src/config.cpp:53)
    note:               /root/Libproxy/zig-cache/o/665b39f8a2bbca92439b4fc67ee647b9/config.o:(populateProxyOptionsFromYAML(ProxyOptions*))
...
trucated

this is the zig build command it tries to run

zig build-exe -lssl -lcrypto -lyaml-cpp -cflags  -- /root/Libproxy/src/config.cpp /root/Libproxy/src/utils.cpp /root/Libproxy/src/trial.cpp -lc++ --cache-dir /root/Libproxy/zig-cache --global-cache-dir /root/.cache/zig --name libproxy -I /root/Libproxy/include --listen=-

when I try to compile it with g++ with almost same flags it works fine

g++ /root/Libproxy/src/config.cpp /root/Libproxy/src/utils.cpp /root/Libproxy/src/trial.cpp -lssl -lcrypto -lyaml-cpp -o bin/LibProxy

am I doing anything wrong??

barren condor
#

c++ is not compatible across compilers, so you have to compile dependencies that use a c++ api with zig

normal yew
#

Ah okay, Thanks!
I didn't know that