Kero
Kero

Reputation: 1

What is the cause of error Undefined symbols for architecture x86_64: "_cmark_markdown_to_html" when building Swift using Docker?

I'm very new to Docker and currently is playing around with pointfreeco to try build and push a website using Docker on Heroku. Going through Heroku's documentation, I've installed Heroku CLI and logged into Heroku account using

$ heroku login

then I logged into the container registry with

$ docker ps

which gives me this output:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Next step is to login into Container Registry using command

$ heroku container:login

and push the app using

$ heroku container:push web

Unfortunately, I've come across this error:

unsupported: unsupported architecture arm64

Run `docker build --platform linux/amd64` to build the image to run on x86_64 architecture.
 ▸    Error: docker push exited with Error: 1

I'm using MacBook Pro M3 Sonoma at the moment. So based on the above error message, I ran this command:

$ docker build --platform linux/amd64 .

after sometime of compiling, here's the output error:

> [build 11/11] RUN swift build -j 1 --configuration release --product Server -Xswiftc -g   && swift build -j 1 --configuration release --product Runner -Xswiftc -g:
0.334 error: Unexpected argument '/usr/bin/swift-build'
0.334 Usage: swift build <options>
0.334   See 'build -help' for more information.
------
Dockerfile:18
--------------------
  17 |
  18 | >>> RUN swift build -j 1 --configuration release --product Server -Xswiftc -g \
  19 | >>>   && swift build -j 1 --configuration release --product Runner -Xswiftc -g
  20 |
--------------------
ERROR: failed to solve: process "/bin/sh -c swift build -j 1 --configuration release --product Server -Xswiftc -g   && swift build -j 1 --configuration release --product Runner -Xswiftc -g" did not complete successfully: exit code: 64

To understand more about the error, I ran individual build command with -v flag:

$ swift build -v --configuration release --product Server -Xswiftc -g

which produces error log as below:

error: link command failed with exit code 1 (use -v to see invocation)
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[20](xml.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[19](utf8.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[18](scanners.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[17](render.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[16](references.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[15](node.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[14](man.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[13](latex.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[12](iterator.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[11](inlines.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[10](html.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[9](houdini_html_u.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[8](houdini_html_e.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[7](houdini_href_e.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[6](commonmark.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[5](cmark_ctype.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[4](cmark.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[3](buffer.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: ignoring file '/opt/homebrew/Cellar/cmark/0.31.0/lib/libcmark.a[2](blocks.c.o)': found architecture 'arm64', required architecture 'x86_64'
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
Undefined symbols for architecture x86_64:
  "_cmark_markdown_to_html", referenced from:
      Views.unsafeMark(from: Swift.String, options: Swift.Int32) -> Swift.String in Markdown.swift.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError

Also, there was a popup to build using Rosetta and I clicked 'OK'. Note that the project is build using SPM. I'm not sure where to go from here. Appreciate any help. Thank you.

Upvotes: 0

Views: 80

Answers (0)

Related Questions