Linking issue

New Member

Linking issue

Hello All,

While doing compilation using makefile I was getting the following error:
ld: Unsatisfied symbol "initialize(int)" in file srv.o
I had also linked the library in which initialize function is there but still I am getting the above error.
I tried using -Wl,-yinitialize option to find what is referencing it but got the following error:
g++: -initialize: linker input file unused because linking not done
I think linking is not done properly.

Kindly help me out.

Dennis Handly
Acclaimed Contributor

Re: Linking issue

If you look closely at the linker message you see the function name with its prototype, that means it is mangled. Your -Wl,-y option will fail because that symbol isn't mangled. But it seems like g++ isn't passing that directly to ld.

You can bypass g++ by doing:
$ export LDOPTS="-Wl,-yinitialize"

If you were using aCC, you could use "-Wf,-o" to see both the mangled and demangled name of your unsat. With your foreign devil driver, you'll have to use "nm -px srv.o | fgrep initialize" to find the mangled name.

If srv.o, is a C source, you need to use:
extern "C" return-type initialize(int);

Then the name won't be mangled.

>I had also linked the library in which initialize function

What does this show?
$ nm -pxA your-lib | fgrep initialize