linking c++ file with a .so file

HI,
I am trying to wrap an existing API with my API. I have written the code in C and C++ for my API and I am trying to link the code with the existing API's .so file. I tried to link it with this command "g++ -shared -Wl,-soname -o flexop.so Flexash.o -DBUILD_DLL -D__linux__ -L. -lnpm" and it did create a new .so file.
But when I try to validate my code with the Python script file , I get teh following errors :

aashishr90@aashishr90-VirtualBox:~/Documents/NpmAbsDll$ python Serial_Power_Cmds.py
Lib name: '/home/aashishr90/Documents/NpmAbsDll/flexop.so'
Traceback (most recent call last):
File "Serial_Power_Cmds.py", line 652, in <module>
main()
File "Serial_Power_Cmds.py", line 608, in main
sp_obj = TM_SP_Cmds(sp_dll_name)
File "Serial_Power_Cmds.py", line 51, in __init__
self._initialize(*args, **kwargs)
File "Serial_Power_Cmds.py", line 80, in _initialize
fail_status = self.SP_DLL.Initialize(ports_buf, status_buf)
File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/aashishr90/Documents/NpmAbsDll/flexop.so: undefined symbol: Initialize
Exception AttributeError: '/home/aashishr90/Documents/NpmAbsDll/flexop.so: undefined symbol: Unload' in <bound method TM_SP_Cmds.__del__ of <__main__.TM_SP_Cmds object at 0x7f4353689ed0>> ignored


I doubt whether the functions in my API are getting exposed. Kindly provide me a solution ofr this.

Thanks
Try supplying an "soname" to the linker:
g++ -shared -Wl,-soname=flexop.so -o flexop.so Flexash.o -DBUILD_DLL -D__linux__ -L. -lnpm

Or remove "-Wl,-soname"
Topic archived. No new replies allowed.