Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to _cork_buffer_append_copy on macOS #174

Open
markand opened this issue Jul 4, 2022 · 0 comments
Open

undefined reference to _cork_buffer_append_copy on macOS #174

markand opened this issue Jul 4, 2022 · 0 comments

Comments

@markand
Copy link

markand commented Jul 4, 2022

Hi,

Trying the latest Git version and compiled all the C files using compiler defaults, on macOS the binary buffer interface fails with the following message:

cc -o main main.o libcork.a
Undefined symbols for architecture x86_64:
  "_cork_buffer_append_copy", referenced from:
      _cork_error_prefix_printf in libcork.a(error.o)
      _cork_error_prefix_string in libcork.a(error.o)
      _cork_error_prefix_vprintf in libcork.a(error.o)
ld: symbol(s) not found for architecture x86_64

The code that generates the error is as simple:

#include <libcork/ds.h>

int
main(void)
{
	struct cork_buffer buf;

	cork_buffer_init(&buf);
	cork_buffer_printf(&buf, "Hello %s", "David");
}

I suspect the CORK_INLINE does something that the compiler dislike because in the libcork.a static library the symbols are not visible.

$ nm libcork.a | grep append_copy
                 U _cork_buffer_append_copy
                 U _cork_buffer_append_copy

I think that's also why most C people recommend to not use inline functions in headers. According to the code, CORK_INLINE is correctly set to inline rather than static in line 158 from attributes.h

@markand markand changed the title undefined reference to _cork_buffer_append_copy undefined reference to _cork_buffer_append_copy on macOS Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant