wangweitl81 / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unexpected 'XML output file may not be null' message when linking without tests #281

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
IMPORTANT NOTE: If you have a question or feature request, please send it
to
googletestframework@googlegroups.com instead (you need to first join the
group at
http://groups.google.com/group/googletestframework).  You'll get an answer
much faster that way.  This issue tracker is for BUG reports only.

If you think you have found a bug in Google Test, please first search the
issue tracker to see if it has been reported.  If this is a new bug, please
provide the
information asked for below.  The more detailed your answer, the more
likely the bug will be fixed.  Thanks.

What steps will reproduce the problem?
1. I changed last 2 line of make/Makefile:

sample1_unittest : sample1.o sample1_unittest.o gtest_main.a
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@

into the following 4 line:

sample.a: sample1.o sample1_unittest.o
    $(AR) $(ARFLAGS) $@ $^
sample1_unittest : sample.a  gtest_main.a
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@

2. then make
3. then run sample1_unittest, output are the following:
Running main() from gtest_main.cc
XML output file may not be null

What is the expected output? What do you see instead?
Is there anything wrong with my change? I expected makefile should have
same effect.

What version of Google Test are you using? On what operating system?
version 1.5 on Ubuntu

Please provide any additional information below, such as a code snippet.

Original issue reported on code.google.com by zheng_xi...@rst.ricoh.com on 6 May 2010 at 7:44

GoogleCodeExporter commented 9 years ago
In general, it is not advisable to put one's tests into an archive.  When the 
error message you see is fixed you'll 
only see this output:

Running main() from gtest_main.cc
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[  PASSED  ] 0 tests.

See this thread for more info: 
http://groups.google.com/group/googletestframework/browse_thread/thread/db90eb23
9482d69d

With regards to the error message, what is the version of Ubuntu you use? What 
is your compiler version? Have 
you modified Makefile or the source code in any other way?

Original comment by vladlosev on 6 May 2010 at 2:52

GoogleCodeExporter commented 9 years ago

Original comment by vladlosev on 6 May 2010 at 2:53

GoogleCodeExporter commented 9 years ago
Is that mean test samples can only be linked as an object file(not an archive)?
Otherwise the sample won't be linked. Is there any reason?  I don't have a deep
understanding of the difference between .o and .a .

Ubuntu version 9.10
gcc version 4.4.1

I only modified Makefile mentioned previously 

Original comment by zheng_xi...@rst.ricoh.com on 7 May 2010 at 1:30

GoogleCodeExporter commented 9 years ago
Yes, unless you modify your code and/or linker options in a specific way. The 
details are in the discussion linked.

Original comment by vladlosev on 7 May 2010 at 1:36

GoogleCodeExporter commented 9 years ago
It seams that I can't open this link. 
http://groups.google.com/group/googletestframework/browse_thread/thread/db90eb23
9482d69d

Can you send the content of link to me? thanks a lot.

Original comment by zheng_xi...@rst.ricoh.com on 7 May 2010 at 1:46

GoogleCodeExporter commented 9 years ago
In short, the GCC linker will not link in a static library unless there are 
references to symbols inside it, unlike an 
object file.

Original comment by vladlosev on 7 May 2010 at 2:45

GoogleCodeExporter commented 9 years ago
Closing per Vlad's comment from May.

Original comment by w...@google.com on 27 Sep 2010 at 7:21