Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Multithreaded libraries of Boost
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Tue Nov 07, 2017 8:49 am    Post subject: Multithreaded libraries of Boost Reply with quote

Good day!

I use Calculate Linux (-amd64).

I installed Boost:
Code:
USE="threads" sudo emerge -av dev-libs/boost
.
And there is multithreaded .so files such as /usr/lib64/libboost_thread-mt.so.

But /sbin/ldconfig -v doesn't show /usr/lib64/libboost_thread-mt.so.
And GCC can't find -lboost_thread-mt's library.

BTW, that's all OK with /usr/lib64/libboost_thread.so and -lboost_thread (without -mt).

Help me, please? Thanks.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10589
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Nov 07, 2017 1:28 pm    Post subject: Reply with quote

Moved from Portage & Programming to Unsupported Software. Not strictly about Gentoo so it fits better here.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Tue Nov 07, 2017 2:27 pm    Post subject: Reply with quote

John R. Graham wrote:
Moved from Portage & Programming to Unsupported Software. Not strictly about Gentoo so it fits better here.

- John


John, do you think it's not ebuild/installation issue?..
Back to top
View user's profile Send private message
nokilli
Apprentice
Apprentice


Joined: 25 Feb 2004
Posts: 196

PostPosted: Tue Nov 07, 2017 2:43 pm    Post subject: Re: Multithreaded libraries of Boost Reply with quote

On my system /usr/lib64/libboost_thread-mt.so is a link to libboost_thread.so, and libboost_thread.so does show up with /sbin/ldconfig -v.

More generally, I'm just wondering if the threads USE flag isn't something that needs to be global. I mean, there be innards and all kinds of icky stuff going on with that I'm sure and I wouldn't want things disagreeing about it.
_________________
Today is the first day of the rest of your Gentoo installation.
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Tue Nov 07, 2017 4:41 pm    Post subject: Re: Multithreaded libraries of Boost Reply with quote

nokilli wrote:
On my system /usr/lib64/libboost_thread-mt.so is a link to libboost_thread.so, and libboost_thread.so does show up with /sbin/ldconfig -v.


But can you use -lboost_thread-mt with GCC?
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 455

PostPosted: Tue Nov 07, 2017 5:10 pm    Post subject: Reply with quote

On gentoo linker finds library for me.
Kind of. Compiled some file and got:

Code:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../lib64/libboost_thread-mt.so: undefined reference to symbol '_ZN5boost6system16generic_categoryEv'
/usr/lib64/libboost_system.so.1.65.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status


Something missing but -lboost_thread-mt was found.
_________________
Sent from Windows
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Tue Nov 07, 2017 5:46 pm    Post subject: Reply with quote

mir3x,

thanks! Does libboost_thread-mt present in /sbin/ldconfig -v?
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10589
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Nov 07, 2017 10:08 pm    Post subject: Reply with quote

kuraga wrote:
John, do you think it's not ebuild/installation issue?..
Not at all. I just think it's not a Gentoo issue. People are free to support threads in Unsupported Software; it's just our way of clearly indicating that it's a non-Gentoo support request.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 455

PostPosted: Tue Nov 07, 2017 11:27 pm    Post subject: Reply with quote

kuraga wrote:
mir3x,

thanks! Does libboost_thread-mt present in /sbin/ldconfig -v?


No, only libboost_thread.so.1.65.0 -> libboost_thread.so.1.65.0
(boost has +thread enabled)

EDIT: ls looks :
ls -l /usr/lib64/libboost_thread*

Code:
lrwxrwxrwx 1 root root     18 10-08 20:11 /usr/lib64/libboost_thread-mt.so -> libboost_thread.so
lrwxrwxrwx 1 root root     25 10-08 20:11 /usr/lib64/libboost_thread.so -> libboost_thread.so.1.65.0
-rwxr-xr-x 1 root root 209256 10-08 20:11 /usr/lib64/libboost_thread.so.1.65.0


EDIT2:
linker is standard one:
ld -v
GNU ld (Gentoo 2.29.1 p3) 2.29.1
EDIT3:
I compiled successfully example here http://www.boost.org/doc/libs/1_54_0/doc/html/lockfree/examples.html

with g++ file.cpp -lboost_thread-mt -lboost_system
without errors.

I tried also clang++ file.cpp -lboost_thread-mt -lboost_system
and it worked also.
_________________
Sent from Windows
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Sun Nov 19, 2017 1:12 pm    Post subject: Reply with quote

Thanks!

Yes, it was some conflicts with other compiler flags (I was compiling a library), cause I also can compile that example.

Sorry. I just thought /sbin/ldconfig should show libbost_threads-mt...
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Sun Nov 19, 2017 2:12 pm    Post subject: Reply with quote

mir3x,

I found a solution! Can you explain me please, one more time? :)

Code:

/usr/bin/c++    -Wall -pthread -fPIC -std=c++11 -O3 -DNDEBUG  -static CMakeFiles/bigartm.dir/srcmain.cc.o CMakeFiles/bigartm.dir/cooccurrence_dictionary.cc.o CMakeFiles/bigartm.dir/__/artm/cpp_interface.cc.o  -o ../../bin/bigartm -rdynamic ../../lib/libmessages_proto.a ../../lib/libartm-static.a ../../lib/libprotobuf.a ../../lib/libgoogle-glog.a -lboost_thread-mt -lboost_program_options-mt -lboost_date_time-mt -lboost_filesystem-mt -lboost_iostreams-mt -lboost_system-mt -lboost_chrono-mt -lboost_timer-mt -lboost_atomic-mt -lboost_regex-mt ../../lib/libmessages_proto.a ../../lib/libinternals_proto.a ../../lib/libgflags.a -lpthread -lpthread

Code:

/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lboost_thread-mt
...

(this is BigARTM library's make, https://github.com/bigartm/bigartm)

Errors disappear, if I do one of the following action:

  • remove -static,
  • change -static to -static-libstdc++,
  • change -static to -static-libgcc,
  • UPDATE: or, BTW, change to non-mt libs.


Can you explain me, please? Is it a conflict of static vs .so-libraries or -static vs -rdynamic options?
Back to top
View user's profile Send private message
mir3x
Guru
Guru


Joined: 02 Jun 2012
Posts: 455

PostPosted: Sun Nov 19, 2017 7:26 pm    Post subject: Reply with quote

I'm not really know all that stuff.

I googled some:

https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Link-Options.html
Code:

-static-libstdc++
When the g++ program is used to link a C++ program, it will normally automatically link against libstdc++. If libstdc++ is available as a shared library, and the -static option is not used, then this will link against the shared version of libstdc++. That is normally fine. However, it is sometimes useful to freeze the version of libstdc++ used by the program without going all the way to a fully static link. The -static-libstdc++ option directs the g++ driver to link libstdc++ statically, without necessarily linking other libraries statically.



So it seems just static doesnt work in that cmake. You can link only some gcc libs static.

Code:
-shared-libgcc
-static-libgcc
On systems that provide libgcc as a shared library, these options force the use of either the shared or static version respectively. If no shared version of libgcc was built when the compiler was configured, these options have no effect.


https://stackoverflow.com/questions/8692128/static-option-for-gcc

Quote:
If you want to use -static, you have to ensure that you have a static version of the C library installed, which might be tricky to find (most systems do not have a static C library any more). Or you have to cancel the effect of -static


I think static linking would require some packages built with "static-libs" or "static" flags.
IMHO by default it should build as shared, look at gentoo packages - they dont built with static libs by default. ( I might be wrong)[/code]

I assume you created that Cmakefile ?
In make Cmake 3.9.6
Boost_USE_STATIC ON - it doesnt exist anymore
Boost_USE_STATIC_LIBS ON - It exist
_________________
Sent from Windows
Back to top
View user's profile Send private message
kuraga
n00b
n00b


Joined: 07 Nov 2017
Posts: 9

PostPosted: Sun Nov 19, 2017 7:33 pm    Post subject: Reply with quote

mir3x,

OK, thanks! No, I want to understand mechanics.

P.S. BTW, I really don't understand why mt and non-mt versions play different. And only one of them is included to /sbin/ldconfig.

Works:
Code:
g++ file.cpp -static -rdynamic -lboost_thread


Doesn't work:
Code:
g++ file.cpp -static -rdynamic -lboost_thread-mt


UPDATE: because of -static. I thought -rdynamic changes mode to dynamic but it doesn't. So GCC is trying to find libboost_thread-mt.a (not libboost_thread-mt.so).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum