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 symbols re: src/compat/compat.h when linking statically #2454

Closed
michaelsbradleyjr opened this issue Dec 11, 2021 · 25 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@michaelsbradleyjr
Copy link
Collaborator

michaelsbradleyjr commented Dec 11, 2021

Not long after I posted the discussion nim-notcurses: a wrapper..., it got difficult for me to make time for it, but I'm excited to try again. 🙂

In that discussion I asked a question about static linking, and you made a recommendation re: pkg-config. That was helpful re: Linux, but not so much for macOS and Windows. However, that's another issue/s which can be discussed separately.

I've worked out this kind of thing re: static linking to libnotcurses-core.a on macOS:

-L/usr/local/opt/ncurses/lib -lncursesw -L/usr/local/opt/libdeflate/lib -ldeflate -L/usr/local/opt/libunistring/lib -lunistring

And I've worked out similar on Linux and Windows.

However, in all cases, static linking ultimately fails with something like this (this paste is from macOS):

Undefined symbols for architecture x86_64:
  "_clock_nanosleep", referenced from:
      _ncvisual_simple_streamer in libnotcurses-core.a(visual.c.o)
  "_pthread_condmonotonic_init", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
  "_set_fd_cloexec", referenced from:
      _getpipes in libnotcurses-core.a(in.c.o)
      _lay_pipes in libnotcurses-core.a(fd.c.o)
  "_set_fd_nonblocking", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
      _stop_inputlayer in libnotcurses-core.a(in.c.o)
      _getpipes in libnotcurses-core.a(in.c.o)
      _launch_pipe_process in libnotcurses-core.a(fd.c.o)
ld: symbol(s) not found for architecture x86_64

After poking around, I found the undefined symbols correspond to declarations in src/compat/compat.h.

I did some naive experiments like adding this near the top of compat.h:

#ifndef __MINGW64__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
#endif

And prefixing e.g. pthread_condmonotonic_init with API extern. But that didn't work.

Any ideas as to whether there's something I may be doing wrong re: how I'm linking statically, or whether there may need to be some adjustments to notcurses' CMakeLists.txt or one/more of its headers?

@michaelsbradleyjr michaelsbradleyjr added the bug Something isn't working label Dec 11, 2021
@michaelsbradleyjr michaelsbradleyjr changed the title Undefined symbols re: src/compat.h Undefined symbols re: src/compat.h when linking statically Dec 11, 2021
@michaelsbradleyjr michaelsbradleyjr changed the title Undefined symbols re: src/compat.h when linking statically Undefined symbols re: src/compat/compat.h when linking statically Dec 11, 2021
@michaelsbradleyjr michaelsbradleyjr added userquestion not quite bugs--inquiries from users and removed bug Something isn't working labels Dec 11, 2021
@dankamongmen dankamongmen self-assigned this Dec 11, 2021
@dankamongmen dankamongmen added this to the 4.0.0 milestone Dec 11, 2021
@dankamongmen
Copy link
Owner

ok so just to make sure i understand, you're trying to link an application to the notcurses static library on macOS, and that's where you see this output?

@dankamongmen
Copy link
Owner

btw i've been unable to get on cobra for about a week

@michaelsbradleyjr
Copy link
Collaborator Author

btw i've been unable to get on cobra for about a week

Very sorry about that, will take a look right away.

@michaelsbradleyjr
Copy link
Collaborator Author

btw i've been unable to get on cobra for about a week

It should be accessible now, can you give it a try?

@dankamongmen
Copy link
Owner

It should be accessible now, can you give it a try?

yep, we good, thanks!

@michaelsbradleyjr
Copy link
Collaborator Author

michaelsbradleyjr commented Dec 11, 2021

ok so just to make sure i understand, you're trying to link an application to the notcurses static library on macOS, and that's where you see this output?

I see similar output on Linux, macOS, and Windows when trying to use static linking in the context of compiling a program with the Nim compiler.

Here's how it goes on macOS:

$ nim c -d:notcursesStatic \
        --passL:"-L/usr/local/opt/ncurses/lib -lncursesw -L/usr/local/opt/libdeflate/lib -ldeflate -L/usr/local/opt/libunistring/lib -lunistring" \
        --threads:on --tlsEmulation:off \
        examples/hello.nim

Gives this output:

Hint: used config file '/Users/michael/.choosenim/toolchains/nim-1.6.0/config/nim.cfg' [Conf]
Hint: used config file '/Users/michael/.choosenim/toolchains/nim-1.6.0/config/config.nims' [Conf]
Hint: used config file '/Users/michael/repos/nim-notcurses/examples/nim.cfg' [Conf]
....................................................................................................................................
# Downloading v3.0.0.tar.gz
# Extracting v3.0.0.tar.gz
# Running cmake .. -G 'Unix Makefiles' -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug
#   Path: /Users/michael/.cache/nim/nimterop/notcurses/debug/buildcache
# Running make
#   Path: /Users/michael/.cache/nim/nimterop/notcurses/debug/buildcache
# Including library /Users/michael/.cache/nim/nimterop/notcurses/debug/buildcache/libnotcurses-core.a
.
# Importing /Users/michael/.cache/nim/nimterop/notcurses/debug/include/notcurses/notcurses.h
# Saved to /Users/michael/.cache/nim/nimterop/toastCache/nimterop_1156088438.nim
..
CC: stdlib_digitsutils.nim
CC: stdlib_assertions.nim
CC: stdlib_dollars.nim
CC: stdlib_system.nim
CC: stdlib_posix.nim
CC: stdlib_times.nim
CC: stdlib_os.nim
CC: ../../../.nimble/pkgs/nimterop-#head/nimterop/globals.nim
CC: stdlib_cpuinfo.nim
CC: hello.nim
Hint:  [Link]
Undefined symbols for architecture x86_64:
  "_clock_nanosleep", referenced from:
      _ncvisual_simple_streamer in libnotcurses-core.a(visual.c.o)
  "_pthread_condmonotonic_init", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
  "_set_fd_cloexec", referenced from:
      _getpipes in libnotcurses-core.a(in.c.o)
      _lay_pipes in libnotcurses-core.a(fd.c.o)
  "_set_fd_nonblocking", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
      _stop_inputlayer in libnotcurses-core.a(in.c.o)
      _getpipes in libnotcurses-core.a(in.c.o)
      _launch_pipe_process in libnotcurses-core.a(fd.c.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: execution of an external program failed: 'clang   -o /Users/michael/repos/nim-notcurses/examples/hello  /Users/michael/.cache/nim/hello_d/stdlib_digitsutils.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_assertions.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_dollars.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_system.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_posix.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_times.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_os.nim.c.o /Users/michael/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimterop-@hhead@snimterop@sglobals.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_cpuinfo.nim.c.o /Users/michael/.cache/nim/hello_d/@mhello.nim.c.o  -lm -lm /Users/michael/.cache/nim/nimterop/notcurses/debug/buildcache/libnotcurses-core.a  -L/usr/local/opt/ncurses/lib -lncursesw -L/usr/local/opt/libdeflate/lib -ldeflate -L/usr/local/opt/libunistring/lib -lunistring  -ldl'

So then I run the clang command with -v as suggested:

clang -v -o /Users/michael/repos/nim-notcurses/examples/hello [all as above]

And I get:

Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.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 -platform_version macos 10.15.0 10.15.6 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o /Users/michael/repos/nim-notcurses/examples/hello -L/usr/local/opt/ncurses/lib -L/usr/local/opt/libdeflate/lib -L/usr/local/opt/libunistring/lib -L/usr/local/lib /Users/michael/.cache/nim/hello_d/stdlib_digitsutils.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_assertions.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_dollars.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_system.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_posix.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_times.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_os.nim.c.o /Users/michael/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimterop-@hhead@snimterop@sglobals.nim.c.o /Users/michael/.cache/nim/hello_d/stdlib_cpuinfo.nim.c.o /Users/michael/.cache/nim/hello_d/@mhello.nim.c.o -lm -lm /Users/michael/.cache/nim/nimterop/notcurses/debug/buildcache/libnotcurses-core.a -lncursesw -ldeflate -lunistring -ldl -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_clock_nanosleep", referenced from:
      _ncvisual_simple_streamer in libnotcurses-core.a(visual.c.o)
  "_pthread_condmonotonic_init", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
  "_set_fd_cloexec", referenced from:
      _getpipes in libnotcurses-core.a(in.c.o)
      _lay_pipes in libnotcurses-core.a(fd.c.o)
  "_set_fd_nonblocking", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
      _stop_inputlayer in libnotcurses-core.a(in.c.o)
      _getpipes in libnotcurses-core.a(in.c.o)
      _launch_pipe_process in libnotcurses-core.a(fd.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Next I run the ld command with -v as suggested:

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -v [all as above]

Yielding:

@(#)PROGRAM:ld  PROJECT:ld64-609.8
BUILD 15:07:46 Dec 18 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
	/usr/local/opt/ncurses/lib
	/usr/local/opt/libdeflate/lib
	/usr/local/opt/libunistring/lib
	/usr/local/lib
	/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
Framework search paths:
	/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "_clock_nanosleep", referenced from:
      _ncvisual_simple_streamer in libnotcurses-core.a(visual.c.o)
  "_pthread_condmonotonic_init", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
  "_set_fd_cloexec", referenced from:
      _getpipes in libnotcurses-core.a(in.c.o)
      _lay_pipes in libnotcurses-core.a(fd.c.o)
  "_set_fd_nonblocking", referenced from:
      _create_inputctx in libnotcurses-core.a(in.c.o)
      _stop_inputlayer in libnotcurses-core.a(in.c.o)
      _getpipes in libnotcurses-core.a(in.c.o)
      _launch_pipe_process in libnotcurses-core.a(fd.c.o)
ld: symbol(s) not found for architecture x86_64

@michaelsbradleyjr
Copy link
Collaborator Author

A similar exercise, with appropriately adjusted --passL:"-L..." for nim c can be done on Linux and Windows, but it's always these same symbols which correspond to declarations (definitions? right terminology?) in src/compat/compat.h that are reported as not found.

It could very well be that the problem is related to how I'm using nimterop with my nim-notcurses wrapper, which is responsible for downloading and cmake+make'ing notcurses. The nimterop approach does work with the notcurses shared library, so maybe there's any extra step/option/something I've missed for static linking.

Anyway, this could be a problem only on my end, or it may be something to do with notcurses itself. I'm just not sure, and after a lot of poking around, I felt stuck so thought to get some extra eyeballs on it. Thanks for at least taking a look; if you're confident the problem is on my end, I'll see if I can get the nimterop maintainers to take a look also.

@dankamongmen
Copy link
Owner

i've no insights yet; i'm totally unlettered regarding Nim. i'm gonna try to look at this tonight or tomorrow, but no promises.

@michaelsbradleyjr
Copy link
Collaborator Author

michaelsbradleyjr commented Dec 12, 2021

i've no insights yet; i'm totally unlettered regarding Nim. i'm gonna try to look at this tonight or tomorrow, but no promises.

Thanks! And sure, I understand you're not familiar with Nim. Maybe I/we could create a minimal kind of example involving static linking and notcurses that doesn't involve Nim, just a simple .c program.

If that works, then it's likely a problem with how I'm presently mis/using nimterop.

@michaelsbradleyjr
Copy link
Collaborator Author

Maybe I/we could create a minimal kind of example... just a simple .c program

I admit this is harder for me than I'd like to admit as I had no real exposure to C/C++ until after I started working with Nim, going on 2 years ago, so there's just a lot I don't know or understand and/or misunderstand.

@dankamongmen
Copy link
Owner

so those symbols oughtn't be getting exported, but they ought be getting built into the libraries that call them. strange.

@dankamongmen
Copy link
Owner

i was definitely able to get a static compile working just now with

gcc -o cli2 cli2.c $(pkg-config --static --libs notcurses)

@michaelsbradleyjr
Copy link
Collaborator Author

michaelsbradleyjr commented Dec 12, 2021

Thanks for the tip re: using src/poc/cli2.c as a testbed. I copied it into another directory and modified it just slightly (notcurses_init -> notcurses_core_init):

#include <notcurses/notcurses.h>

int main(void){
  struct notcurses_options opts = {
    .flags = NCOPTION_NO_ALTERNATE_SCREEN |
             NCOPTION_PRESERVE_CURSOR |
             NCOPTION_NO_CLEAR_BITMAPS |
             NCOPTION_DRAIN_INPUT,
  };
  struct notcurses* nc = notcurses_core_init(&opts, NULL);
  if(nc == NULL){
    return EXIT_FAILURE;
  }
  notcurses_render(nc);
  notcurses_stop(nc);
  return EXIT_SUCCESS;
}

On macOS, with notcurses v3.0.0 installed with homebrew, when I do:

$ clang -o cli2 cli2.c $(pkg-config --static --libs notcurses-core)

It works, but it's definitely not performing static linking:

$ otool -L cli2
cli2:
	/usr/local/opt/notcurses/lib/libnotcurses-core.3.dylib (compatibility version 3.0.0, current version 3.0.0)
	/usr/local/opt/libunistring/lib/libunistring.2.dylib (compatibility version 4.0.0, current version 4.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)

The cli2 executable is clearly linked to several shared libs (.dylib files)

What I want to do is (I think) more like this:

clang -o cli2 cli2.c -Wl,/usr/local/opt/notcurses/lib/libnotcurses-core.a,/usr/local/opt/ncurses/lib/libncursesw.a,/usr/local/opt/libdeflate/lib/libdeflate.a,/usr/local/opt/libunistring/lib/libunistring.a

But that gives me the following error, complaining about the same symbols re: src/compat/compat.h as before (except this time the Nim compiler isn't involved in any way):

Undefined symbols for architecture x86_64:
  "_clock_nanosleep", referenced from:
      _ncvisual_simple_streamer in libnotcurses-core.a(visual.c.o)
  "_pthread_condmonotonic_init", referenced from:
      _init_inputlayer in libnotcurses-core.a(in.c.o)
  "_set_fd_cloexec", referenced from:
      _getpipes in libnotcurses-core.a(in.c.o)
      _ncexecvpe in libnotcurses-core.a(fd.c.o)
  "_set_fd_nonblocking", referenced from:
      _init_inputlayer in libnotcurses-core.a(in.c.o)
      _stop_inputlayer in libnotcurses-core.a(in.c.o)
      _getpipes in libnotcurses-core.a(in.c.o)
      _ncexecvpe in libnotcurses-core.a(fd.c.o)
ld: symbol(s) not found for architecture x86_64

@dankamongmen
Copy link
Owner

doh i'm retarded; we needed a --static there, in which case yes i also get a blowup, sorry

@michaelsbradleyjr
Copy link
Collaborator Author

michaelsbradleyjr commented Dec 12, 2021

So one I thing I happen to know about is that Apple for years now has actively un-supported static linking to /usr/lib/libSystem.B.dylib.

In practice what that means is that you can static link to everything else you want (e.g. stuff from homebrew), but the core runtime stuff (not sure if that's the correct terminology, but in any case it's /usr/lib/libSystem.B.dylib) has to be linked as a shared library. That's why clang compiler/linker on macOS doesn't even support a -static argument (i.e. the cli option is there but it doesn't succeed).

Now, in practice, I have in the past successfully built executables that were statically linked to everything but /usr/lib/libSystem.B.dylib and I could copy them around to other macs that didn't have the stuff installed from homebrew that was on the machine I used to do the compilation. But... that was always in the context of the Nim compiler I guess taking care of some magic spell to make sure that the needed link to /usr/lib/libSystem.B.dylib happened correctly. If or how that has any bearing on the symbols re: notcurses' src/compat/compat.h not being found, I'm not sure, but maybe?

Or maybe not if you're saying you get the same blowup with -static passed to gcc on e.g. Linux.

@dankamongmen
Copy link
Owner

[schwarzgerat](1) $ gcc -pthread --static -o cli2-static cli2.c libnotcurses.a libnotcurses-core.a /usr/lib/x86_64-linux-gnu/libtinfo.a  /usr/lib/x86_64-linux-gnu/libdeflate.a 
/usr/bin/ld: libnotcurses-core.a(util.c.o): in function `notcurses_accountname':
/home/dank/src/dankamongmen/notcurses/src/lib/util.c:42: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: libnotcurses-core.a(notcurses.c.o): in function `utf8_egc_len':
/home/dank/src/dankamongmen/notcurses/src/lib/egcpool.h:110: undefined reference to `uc_is_grapheme_break'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/egcpool.h:114: undefined reference to `uc_is_property_variation_selector'
/usr/bin/ld: libnotcurses-core.a(notcurses.c.o): in function `notcurses_ucs32_to_utf8':
/home/dank/src/dankamongmen/notcurses/src/lib/notcurses.c:3198: undefined reference to `u32_to_u8'
/usr/bin/ld: /tmp/cc6yOnRy.o: in function `main':
cli2.c:(.text+0x6b): undefined reference to `notcurses_render'
/usr/bin/ld: libnotcurses-core.a(direct.c.o): in function `utf8_egc_len':
/home/dank/src/dankamongmen/notcurses/src/lib/egcpool.h:110: undefined reference to `uc_is_grapheme_break'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/egcpool.h:114: undefined reference to `uc_is_property_variation_selector'
/usr/bin/ld: libnotcurses-core.a(in.c.o): in function `create_inputctx':
/home/dank/src/dankamongmen/notcurses/src/lib/in.c:1610: undefined reference to `pthread_condmonotonic_init'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/in.c:1612: undefined reference to `pthread_condmonotonic_init'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/in.c:1619: undefined reference to `set_fd_nonblocking'
/usr/bin/ld: libnotcurses-core.a(in.c.o): in function `stop_inputlayer':
/home/dank/src/dankamongmen/notcurses/src/lib/in.c:2290: undefined reference to `set_fd_nonblocking'
/usr/bin/ld: libnotcurses-core.a(visual.c.o): in function `ncvisual_rotate':
/home/dank/src/dankamongmen/notcurses/src/lib/visual.c:707: undefined reference to `sin'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/visual.c:708: undefined reference to `cos'
/usr/bin/ld: libnotcurses-core.a(fd.c.o): in function `launch_pipe_process':
/home/dank/src/dankamongmen/notcurses/src/lib/fd.c:233: undefined reference to `set_fd_nonblocking'
/usr/bin/ld: libnotcurses-core.a(metric.c.o): in function `ncnmetric':
/home/dank/src/dankamongmen/notcurses/src/lib/metric.c:29: undefined reference to `fesetround'
collect2: error: ld returned 1 exit status
[schwarzgerat](1) $ 

ok, this seems to be pretty much what you're running into, yeah?

@dankamongmen
Copy link
Owner

[schwarzgerat](1) $ gcc -pthread --static -o cli2-static cli2.c libnotcurses.a libnotcurses-core.a /usr/lib/x86_64-linux-gnu/libtinfo.a  /usr/lib/x86_64-linux-gnu/libdeflate.a /usr/lib/x86_64-linux-gnu/libunistring.a /usr/lib/x86_64-linux-gnu/libm.a 
/usr/bin/ld: libnotcurses-core.a(util.c.o): in function `notcurses_accountname':
/home/dank/src/dankamongmen/notcurses/src/lib/util.c:42: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/ccuiEev9.o: in function `main':
cli2.c:(.text+0x6b): undefined reference to `notcurses_render'
/usr/bin/ld: libnotcurses-core.a(in.c.o): in function `create_inputctx':
/home/dank/src/dankamongmen/notcurses/src/lib/in.c:1610: undefined reference to `pthread_condmonotonic_init'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/in.c:1612: undefined reference to `pthread_condmonotonic_init'
/usr/bin/ld: /home/dank/src/dankamongmen/notcurses/src/lib/in.c:1619: undefined reference to `set_fd_nonblocking'
/usr/bin/ld: libnotcurses-core.a(in.c.o): in function `stop_inputlayer':
/home/dank/src/dankamongmen/notcurses/src/lib/in.c:2290: undefined reference to `set_fd_nonblocking'
/usr/bin/ld: libnotcurses-core.a(fd.c.o): in function `launch_pipe_process':
/home/dank/src/dankamongmen/notcurses/src/lib/fd.c:233: undefined reference to `set_fd_nonblocking'
collect2: error: ld returned 1 exit status
[schwarzgerat](1) $ 

ahhh thar we go

@dankamongmen
Copy link
Owner

fix incoming

@dankamongmen
Copy link
Owner

hrmmm, no, surprising, that didn't get it...

@dankamongmen
Copy link
Owner

should be fixed

@dankamongmen
Copy link
Owner

[schwarzgerat](0) $ gcc -D_XOPEN_SOURCE=500 -I../include -pthread --static -o cli2-static cli2.c libnotcurses.a libnotcurses-core.a /usr/lib/x86_64-linux-gnu/libtinfo.a  /usr/lib/x86_64-linux-gnu/libdeflate.a /usr/lib/x86_64-linux-gnu/libunistring.a /usr/lib/x86_64-linux-gnu/libm.a 
/usr/bin/ld: libnotcurses-core.a(util.c.o): in function `notcurses_accountname':
/home/dank/src/dankamongmen/notcurses/src/lib/util.c:42: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
[schwarzgerat](0) $ 

@dankamongmen dankamongmen added bug Something isn't working and removed userquestion not quite bugs--inquiries from users labels Dec 12, 2021
@dankamongmen
Copy link
Owner

we just weren't compiling the compat.c into the static library, dumb. i need to add a target that links up statically so we verify that this keeps working. also, all of that crap you're having to list ought be getting put into the pkg-confg file, i would think.

@michaelsbradleyjr
Copy link
Collaborator Author

Awesome, thanks for taking a look and for finding such a quick fix. I'll give it a spin tomorrow, for sure.

all of that crap you're having to list ought be getting put into the pkg-confg file, i would think

That would be nice, though I think I was running into some problems with pkg-config on mac and windows; I'll give that another look tomorrow, may have been user error on my part.

@dankamongmen dankamongmen modified the milestones: 4.0.0, 3.1.0 Dec 12, 2021
KristofferC pushed a commit to KristofferC/notcurses that referenced this issue Dec 13, 2021
@michaelsbradleyjr
Copy link
Collaborator Author

michaelsbradleyjr commented Dec 13, 2021

we just weren't compiling the compat.c into the static library...

Awesome, thanks for taking a look and for finding such a quick fix. I'll give it a spin tomorrow, for sure.

The changes you made re: "compiling the compat.c into the static library" worked great, thanks!

There are some troubles with pkg-config re: static linking, on macOS at least, that will require more thought on my part... or I may need to give up on my "nimterop + static linking" approach now that I'm learning more of the pitfalls, i.e. simply rely on notcurses to have been installed with apt or brew or whatever and link to it as a shared library.

@dankamongmen
Copy link
Owner

There are some troubles with pkg-config re: static linking, on macOS at least, that will require more thought on my part... or I may need to give up on my "nimterop + static linking" approach now that I'm learning more of the pitfalls, i.e. simply rely on notcurses to have been installed with apt or brew or whatever.

yeah, i came to the same conclusion. all that manual listing of libraries oughtn't be necessary. i intend to look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants