C/C++ link problems

S

stephen henry

Hi all,

Please help me...

I have two projects: systemc (written in C++) and x264 (written in C).
I would like to have a C++ project that that can call both systemc
functions and x264 functions. What I've done is I've linked both
libraries into my project, using an additional header file to include
the C functions from x264 as follows:

#ifndef __x264__h__
#define __x264__h__

extern "C" {

#include "../x264/...";

// include all the x264 headers here.

}

The project seems to compile fine, however when it gets to the linking
stage it complains that it can't find a bunch of functions. What I'm
having difficulty with is the fact that I'm using g++ (and explicitly
linking in the stdc++ library) and the functions it can't find all
relate to C++ functions, either in the standard library or in systemc.
Previous usenet posts suggest that I may be using gcc opposed to g++,
but, as my log shows, I am using the correct compiler. Even odder is
the fact that it doesn't report that it can't find the x264 C
functions I use (at least to my knowledge).

When I run make I get (just a bit of the output):

In file included from algorithm/x264/core/common.h:35,
from algorithm/x264.h:15,
from arch/src/camera.h:10,
from arch/src/camg++ -Wno-deprecated -g -Wall -I.
-I.. -I./algorithm -I./algorithm/core -I./algorithm/encoder In file
included from algorithm/x264/core/common.h:35,
from alg++ -Wno-deprecated -g -Wall -I. -I..
-I./algorithm -I./algorithm/core -I./algorithm/encoder -Isystemc
-I../common/systemc/include -L. -L.. -L../common/systemc/lib-linux
-L./algorithm/x26../common/systemc/lib-linux/libsystemc.a(sc_main.o):
In function `_GLOBAL__I_sc_in_action':
sc_main.o(.text+0xc): undefined reference to
`std::ios_base::Init::Init[in-charge]()'
.../common/systemc/lib-linux/libsystemc.a(sc_main.o): In function
`main':
sc_main.o(.text+0x8b): undefined reference to `__cxa_begin_catch'
sc_main.o(.text+0x92): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
sc_main.o(.text+0xa7): undefined reference to `std::cout'
sc_main.o(.text+0xac): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0xb5): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0xbe): undefined reference to
`std::basic_ostream said:
::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
sc_main.o(.text+0xc6): undefined reference to `__cxa_end_catch'
sc_main.o(.text+0xd5): undefined reference to `__cxa_begin_catch'
sc_main.o(.text+0xe4): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
sc_main.o(.text+0xf5): undefined reference to `std::cout'
sc_main.o(.text+0xfa): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0x103): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0x10c): undefined reference to
`std::basic_ostream said:
::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
sc_main.o(.text+0x117): undefined reference to `__cxa_begin_catch'
sc_main.o(.text+0x11e): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
sc_main.o(.text+0x12f): undefined reference to `std::cout'
sc_main.o(.text+0x134): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0x13d): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_main.o(.text+0x146): undefined reference to
`std::basic_ostream said:
::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
sc_main.o(.text+0x153): undefined reference to `__cxa_end_catch'
sc_main.o(.text+0x15c): undefined reference to `_Unwind_Resume'
.../common/systemc/lib-linux/libsystemc.a(sc_main.o): In function
`__tcf_0':
sc_main.o(.text+0x3c): undefined reference to
`std::ios_base::Init::~Init [in-charge]()'
.../common/systemc/lib-linux/libsystemc.a(sc_main.o)(.gcc_except_table+0x2c):
undefined reference to `typeinfo for char const*'
.../common/systemc/lib-linux/libsystemc.a(sc_main.o)(.eh_frame+0x12):
undefined reference to `__gxx_personality_v0'
.../common/systemc/lib-linux/libsystemc.a(sc_simcontext.): In function
`_GLOBAL__I__ZN16sc_process_tableC2Ev':
sc_simcontext.(.text+0x19c): undefined reference to
`std::ios_base::Init::Init[in-charge]()'
.../common/systemc/lib-linux/libsystemc.a(sc_simcontext.): In function
`sc_simcontext::crunch()':
sc_simcontext.(.text+0x669): undefined reference to `_Unwind_Resume'
sc_simcontext.(.text+0x69f): undefined reference to
`__cxa_begin_catch'
sc_simcontext.(.text+0x6a6): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
sc_simcontext.(.text+0x6bf): undefined reference to `std::cout'
sc_simcontext.(.text+0x6c4): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_simcontext.(.text+0x6cd): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::eek:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)'
sc_simcontext.(.text+0x6d6): undefined reference to
`std::basic_ostream said:
::eek:perator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
sc_simcontext.(.text+0x6e2): undefined reference to `__cxa_end_catch'


Thanks for your help.

Stephen
 
V

Victor Bazarov

stephen said:

<offtopic>
Link errors, especially "unresolved externals" or "undefined
references", are almost always due to the fact that some
library file is missing from the list of libraries supplied
to the linker. As I encountered recently, UNIX linkers are
single-pass, so, if you have two libraries referring to each
other, you need to mention those libraries twice. Make sure
you have all necessary libraries mentioned and in the right
order.
</offtopic>

Link errors have very little to do with the language. Please
post your further inquiries to a newsgroup that deals with
your compiler. gnu.g++.help seems right.

V
 
E

Evan Carew

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephen,

Could you tell us what your link line looked like?

Evan

stephen said:
Hi all,

Please help me...

I have two projects: systemc (written in C++) and x264 (written in C).
I would like to have a C++ project that that can call both systemc
functions and x264 functions. What I've done is I've linked both
libraries into my project, using an additional header file to include
the C functions from x264 as follows:


Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBWhbyoo/Prlj9GScRAsFAAJ94KkfYpLRYimfi67IXQri1UlPujQCfQh9u
6DnvTqw+q+58aCBKRzjHoV0=
=cJrl
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top