Discussion:
Issues in building a shared library
(too old to reply)
Arun
2012-01-10 06:12:00 UTC
Permalink
Raw Message
Hello,
I am trying to build a shared library called "libjxx.so" using Visual
studio2008 V9.0. The module contains both C & fortran routines. I am
making the C-source as start up project and linking the F-source
against it. I am also linking couple of other libraries called
libm7.lib & libm8.lib. I am getting the following errors concerning
undefined references.

libjxx_F.lib(jmxx_cmd.obj) : error LNK2019: unresolved external
symbol
half_initialise_ referenced in function jm45_init_
libjxx_F.lib(jmxx_cmd.obj) : error LNK2019: unresolved external
symbol
half_get_error_msg_ referenced in function jm45_init_
libjxx_F.lib(jmxx_read.obj) : error LNK2001: unresolved external
symbol half_get_error_msg_
libjxx_F.lib(jmxx_write.obj) : error LNK2001: unresolved external
symbol half_get_error_msg_


These symbols are basically present in libm7.lib. I am sure i am
linking this library correctly with paths are in place in the
"Additional library directories" section. Also i am inputting the
additional directories in correct linking order ie., after the
concerned module. My suspicion is that i am linking a ".lib" which is
nothing but a static library to form a final shared library (.so).
Should libm7 be compiled as a shared module and then linked against
the sources of libjxx? I am not pretty sure on this.


Any ideas or suggestions in this regard would be highly appreciated.
Thanks in advance,
Arun
Cholo Lennon
2012-01-12 18:37:29 UTC
Permalink
Raw Message
Post by Arun
Hello,
I am trying to build a shared library called "libjxx.so" using Visual
studio2008 V9.0.
I can see that you come from unix (or a related OS): this is Windows,
you should build a dynamic library, so 'libjxx.dll' would be the correct
name.
Post by Arun
The module contains both C& fortran routines. I am
making the C-source as start up project and linking the F-source
against it. I am also linking couple of other libraries called
libm7.lib& libm8.lib. I am getting the following errors concerning
undefined references.
libjxx_F.lib(jmxx_cmd.obj) : error LNK2019: unresolved external
symbol
half_initialise_ referenced in function jm45_init_
libjxx_F.lib(jmxx_cmd.obj) : error LNK2019: unresolved external
symbol
half_get_error_msg_ referenced in function jm45_init_
libjxx_F.lib(jmxx_read.obj) : error LNK2001: unresolved external
symbol half_get_error_msg_
libjxx_F.lib(jmxx_write.obj) : error LNK2001: unresolved external
symbol half_get_error_msg_
These symbols are basically present in libm7.lib. I am sure i am
linking this library correctly with paths are in place in the
"Additional library directories" section. Also i am inputting the
additional directories in correct linking order ie., after the
concerned module. My suspicion is that i am linking a ".lib" which is
nothing but a static library to form a final shared library (.so).
Should libm7 be compiled as a shared module and then linked against
the sources of libjxx? I am not pretty sure on this.
Is 'libm7.lib' an static library or an import library? Try using
'dumpbin' utility from a Visual Studio console in order to check the
libm7.lib symbols.

In case you have an import library check if the function exports (in c
headers) are well managed (check
http://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx in case you don't
know how to export/import a function to/from a dynamic library)
Post by Arun
Any ideas or suggestions in this regard would be highly appreciated.
How are you passing the libraries to the linker? You should use the
complete name (i.e. 'libm7.lib', not 'm7' like gcc -l option)
Post by Arun
Thanks in advance,
Arun
Best Regards
--
Cholo Lennon
Bs.As.
ARG
Loading...