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

Issues with pthreads on compiling #391

Closed
GoogleCodeExporter opened this issue Jul 28, 2015 · 6 comments
Closed

Issues with pthreads on compiling #391

GoogleCodeExporter opened this issue Jul 28, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link
Contributor

IMPORTANT NOTE: PLEASE send issues or requests to
http://groups.google.com/group/googletestframework *instead of here*.
This issue tracker is NOT regularly monitored.

If you really need to create a new issue, please provide the information
asked for below.

What steps will reproduce the problem?
1.Download the gtest-1.6.0
2.cd to the make directory
3.run the `sample1_unittest`

What is the expected output? What do you see instead?
Normally, the build is suppose to go on without any errors. Instead, a list of 
missing references relating to pthreads are output.

What version of Google Test are you using? On what operating system?
Google test 1.6.0, GCC 4.6.1, Ubuntu 10.10 Oneiric Ocelot.

Please provide any additional information below, such as a code snippet.
It seems that in ubuntu 10.10, at the last stage of linking the gtest library 
and test source file, -pthread should be used instead of -lpthread.

Original issue reported on code.google.com by Briandkid on 21 Nov 2011 at 2:24

Attachments:

@GoogleCodeExporter
Copy link
Contributor Author

this is due to the linker flag ld --as-needed being default in ubuntu.
the -lpthread must be placed after all objects needing its symbols or -pthread 
should be used.

Original comment by jtaylor....@googlemail.com on 2 May 2012 at 5:48

@GoogleCodeExporter
Copy link
Contributor Author

http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
It makes a difference where in the command you write this option; the linker 
searches and processes libraries and object files in the order they are 
specified

so we need to put -lpthread followed by objects or source file

I attached this patch

Original comment by Lynn.Xin...@gmail.com on 27 Sep 2012 at 6:37

Attachments:

@GoogleCodeExporter
Copy link
Contributor Author

Quite a number of people are running into this issue. I did not have any 
problems under OSX 10.8.2 (perhaps because gcc are soft links to lvm), but as 
soon as I moved my code to Ubuntu 12.04 I ran into this issue.

Easy fix, but quite a hassle.

See http://stackoverflow.com/questions/10315016/error-during-making-gtest

Original comment by r...@burhum.com on 9 Dec 2012 at 7:26

@GoogleCodeExporter
Copy link
Contributor Author

Some fix steps:
What steps will reproduce the problem?
1.Download the gtest-1.6.0
2.cd make/
3.make
4.PROFIT!...

Today i`m first try google test for C++ and have spend over hours to install 
it. Its quite wobbly to find a very OLD bug. And fix it.

$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -pthread $^ -o $@
-pthread should be used instead of -lpthread

Thanks for all users who have found this bug over two years ago!

Original comment by kiril.sa...@gmail.com on 29 Jul 2013 at 11:50

@gldneagl
Copy link

after several years the code still hasn't been fixed

@gennadiycivil
Copy link
Contributor

@gldneagl The best way to approach this would be to create a proper PR and submit it for consideration. The fact that this issue has not beed addressed indicates that it is simply not an issue for the community

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

4 participants
@gldneagl @GoogleCodeExporter @gennadiycivil and others