This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why does linker fail to resolve dependencies within the same .a file?
- From: "Christian Convey" <christian dot convey at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 28 Feb 2007 00:05:39 -0500
- Subject: Why does linker fail to resolve dependencies within the same .a file?
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=BdruHFXCKjt33ZYIbos97V096F7QfM+18a7B7DC9HL0aowllg5HlUT/t6tTxYffYotfDCNhXHYU3oodAe6XeSAqPtsbgDS+mR/kCsZFnnmZIgF+vUEQHheyJ8FI/FDEXaapzyaJLFkGwQkwQIdxmbb1qvoq8g9Y+Oc7SYl0ggWQ=
I'm using CMake to build a library (as a .a file) and a demo program
for that library.
My problem is that when I go to link that demo program, I get a linker
error that says one file function in the .a file can't find another
function in the .a file. Here's what the linker command line and
error output look like:
Linking CXX executable simpleIO
cd /home/cjc/csc583-svn/uriVisionLib/trunk/SDK/Demos/C++/Basic/Simple_IO
&& /home/cjc/packages/CMake/bin/cmake -P
CMakeFiles/simpleIO.dir/cmake_clean_target.cmake
cd /home/cjc/csc583-svn/uriVisionLib/trunk/SDK/Demos/C++/Basic/Simple_IO
&& /usr/bin/c++ -fPIC "CMakeFiles/simpleIO.dir/main_IO.o" -o
simpleIO -rdynamic
-L/home/cjc/csc583-svn/uriVisionLib/trunk/Development/Source/C++ -lGL
-lglut -Wl,-Bstatic -luriVision -luriVision -Wl,-Bdynamic
-Wl,-rpath,/home/cjc/csc583-svn/uriVisionLib/trunk/Development/Source/C++
/home/cjc/csc583-svn/uriVisionLib/trunk/Development/Source/C++/liburiVision.a(ImageReader.o):
In function `uriVideoSources::ImageReader::getFrame(bool,
uriBase::RasterImage*)':
ImageReader.cpp:(.text+0x90): undefined reference to
`uriVideoSources::ImageReader_gen::getFrame_(bool,
uriBase::RasterImage*)'
(there are more errors as well, but I figured this was enough to make my point).
I thought that perhaps the supposedly missing function wasn't in the
.a file, so I check with nm as follows:
cjc@peace:~$ nm --demangle
/home/cjc/csc583-svn/uriVisionLib/trunk/Development/Source/C++/liburiVision.a
| grep outputFrame
0000002c T uriMovieEditing::ImageWriter::outputFrame(uriBase::RasterImage*)
00000000 T uriMovieEditing::ImageWriter::outputFrame(uriBase::RasterImage*,
bool)
U uriMovieEditing::ImageWriter_gen::outputFrame_(uriBase::RasterImage*,
bool)
So it appears to be in there. I also thought that maybe this was one
of the cases where I needed to list the .a file twice on the linker
command line, but the linker invocation / output shown above already
reflects my doing that (I think).
Does anyone know where I might be going wrong here?
Thanks,
Christian