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

Is it possible to build statically? #1

Closed
maiha opened this issue Jul 19, 2020 · 10 comments
Closed

Is it possible to build statically? #1

maiha opened this issue Jul 19, 2020 · 10 comments

Comments

@maiha
Copy link
Contributor

maiha commented Jul 19, 2020

Compilation with --enable-static --disable-shared fails.

  • tkrzw: (master) b65530d DBM::Increment method supports the read-only mode.
  • g++: g++ (Ubuntu 7.5.0-6ubuntu2) 7.5.0
$ ./configure --enable-static --disable-shared

$ make
(...snip...)
g++ -g -O2 -std=c++17 -Wall -fPIC -fsigned-char -g0 -O2 -o tkrzw_build_util tkrzw_build_util.o -L. -L/usr/local/lib -L/usr/local/lib -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib: -Wl,--as-needed -L. -L/usr/local/lib -L/usr/local/lib -static -ltkrzw -lstdc++ -lrt -lpthread -lm -lc  -lstdc++ -lrt -lpthread -lm -lc

/usr/bin/ld: ./libtkrzw.a(tkrzw_cmd_util.o): in function `tkrzw::FileIndex::Iterator::Iterator(std::unique_ptr<tkrzw::DBM::Iterator, std::default_delete<tkrzw::DBM::Iterator> >)':
tkrzw_cmd_util.cc:(.text+0x160): multiple definition of `tkrzw::FileIndex::Iterator::Iterator(std::unique_ptr<tkrzw::DBM::Iterator, std::default_delete<tkrzw::DBM::Iterator> >)'; tkrzw_build_util.o:tkrzw_build_util.cc:(.text+0x180): first defined here
/usr/bin/ld: ./libtkrzw.a(tkrzw_cmd_util.o): in function `tkrzw::FileIndex::Iterator::Iterator(std::unique_ptr<tkrzw::DBM::Iterator, std::default_delete<tkrzw::DBM::Iterator> >)':
(...snip...)
collect2: error: ld returned 1 exit status
make: *** [Makefile:602: tkrzw_build_util] Error 1

Best regards,

@estraier
Copy link
Owner

Thanks for pointing it out.
I'd forgotten to add "inline" modifiers. I pushed the fix.
However, there's another problem with the static linking; Pthread doesn't work with static linking.
I'm looking for a solution now.

@maiha
Copy link
Contributor Author

maiha commented Jul 19, 2020

Yep! It worked with master!

  • f9dbdc2 Add the inline modifier to fix errors with static linking.
$ make
$ ldd ./tkrzw_dbm_util
        not a dynamic executable

I'm also looking forward to supporting pthreads for the static link version. Thank you very much.

@maiha maiha closed this as completed Jul 19, 2020
@estraier
Copy link
Owner

I fixed the issue for pthread static linking. It's been already pushed.
Now, you can run "make check" even with "configure --enable-static".

@maiha
Copy link
Contributor Author

maiha commented Jul 19, 2020

You work fast! And great job! ㊗️ 💯 👍

@lumina7
Copy link

lumina7 commented Jul 20, 2020

Sorry to be of topic.
@maiha, Is a crystal client for tkrzw coming?

The successor of tokyocabinet/kyotocabinet is here, dreams do come true after all!!! :)
Christmas is early this year.

@maiha
Copy link
Contributor Author

maiha commented Jul 21, 2020

Hi @lumina7
Yep, that's the plan. For now, I just created the repository. 😄
https://github.com/maiha/tkrzw.cr

@pfalcon
Copy link

pfalcon commented Dec 19, 2020

Pthread doesn't work with static linking.

Did you consider making pthread support optional in the first place?

@estraier
Copy link
Owner

estraier commented Dec 20, 2020 via email

@kostya
Copy link

kostya commented Jan 16, 2022

btw, why static library so big? 80Mb. and like + ~30Mb for binary which liked it. May be it links some unnesessary things?

@estraier
Copy link
Owner

estraier commented Jan 16, 2022 via email

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

5 participants