google / wuffs

Wrangling Untrusted File Formats Safely
Other
4.07k stars 129 forks source link

Add Bazel support to hello-wuffs-c example code #47

Open davidmankin opened 3 years ago

davidmankin commented 3 years ago

I'd like to contribute example code to hello-wuffs-c example so that it's easier for people using Bazel to get started using wuffs-the-language.

I spent a long time hacking at it and I think I have something close to working, but when it comes to the linker step I'm getting these errors and I don't know enough C to know what it's talking about

... external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-fastbuild/bin/src/main/wuffs/hello-wuffs/hello-c-2.params)
Apple clang version 11.0.0 (clang-1100.0.33.16)
Target: x86_64-apple-darwin18.7.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/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.15.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -o bazel-out/darwin-fastbuild/bin/src/main/wuffs/hello-wuffs/hello-c -lc++ -S bazel-out/darwin-fastbuild/bin/src/main/wuffs/hello-wuffs/_objs/hello-c/main.o bazel-out/darwin-fastbuild/bin/src/main/wuffs/hello-wuffs/libparse.a -framework Foundation -lobjc -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_sizeof__wuffs_demo__parser", referenced from:
      _parse in main.o
  "_wuffs_demo__parser__initialize", referenced from:
      _parse in main.o
  "_wuffs_demo__parser__parse", referenced from:
      _parse in main.o
  "_wuffs_demo__parser__value", referenced from:
      _parse in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
davidmankin commented 3 years ago

Never mind about that problem: I was missing #define WUFFS_IMPLEMENTATION in main.c

I'll work on getting a bazel example PR ready to review.