Error while LoadLibrary a c-shared .so in CentOS

1 回表示 (過去 30 日間)
Varun Pai
Varun Pai 2019 年 5 月 21 日
編集済み: Varun Pai 2019 年 5 月 21 日
I have created a C application and built it as a C-Shared library .so. The C application contains reference to ZMQ library. To generate the shared library I tried following steps:
1) I wrote a C application ZMQInterface.c with a header file ZMQInterface.h
2) Built the application as C-shared library
[varun@localhost zmqproj]$ gcc -c -Wall -Werror -I/usr/local/include/ -L/usr/local/lib -lzmq -fpic ZMQInterface.c
[varun@localhost zmqproj]$ gcc -shared -o ZMQInterface.so ZMQInterface.o
The shared library ZMQInterface.so was generated successfully
When I tried to load it in MATLAB using loadlibrary() I am getting the following error. I have attached the files (zmqproj.zip)
>> [status,warn] = loadlibrary('ZMQInterface.so','ZMQInterface.h');
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********
Type '' was not found. Defaulting to type error.
Found on line 11 of input from line 5 of file /home/varun/zmqproj/ZMQInterface.h
Type 'char(visibility("default")))Ptrs_recv(voidPtr' was not found. Defaulting to type voidPtr.
Found on line 11 of input from line 5 of file /home/varun/zmqproj/ZMQInterface.h
Type '' was not found. Defaulting to type error.
Found on line 12 of input from line 6 of file /home/varun/zmqproj/ZMQInterface.h
Failed to parse type '( visibility (" default "))) void * create_socket_context ( void' original input '( visibility (" default "))) void * create_socket_context ( void '
Found on line 12 of input from line 6 of file /home/varun/zmqproj/ZMQInterface.h
Error parsing argument for function __attribute__ function may be invalid.
Type '' was not found. Defaulting to type error.
Found on line 13 of input from line 7 of file /home/varun/zmqproj/ZMQInterface.h
Type 'int(visibility("default")))voidPtrcreate_socket_subscriber(voidPtr' was not found. Defaulting to type voidPtr.
Found on line 13 of input from line 7 of file /home/varun/zmqproj/ZMQInterface.h
*********
Error using loadlibrary
Building ZMQInterface_thunk_glnxa64 failed. Compiler output is:
/usr/bin/gcc -I"/usr/local/MATLAB/R2017a/extern/include" -fexceptions -fPIC -fno-omit-frame-pointer -pthread -I"/home/varun/zmqproj"
-I"/home/varun/zmqproj" "ZMQInterface_thunk_glnxa64.c" -o "ZMQInterface_thunk_glnxa64.so" -Wl,-E -shared
ZMQInterface_thunk_glnxa64.c: In function voidPtrThunk:
ZMQInterface_thunk_glnxa64.c:38:14: error: expected expression before ‘)’ token
return (( (*)(void * ))fcn)(p0);
^
ZMQInterface_thunk_glnxa64.c:38:25: error: expected )before ‘fcn’
return (( (*)(void * ))fcn)(p0);
^
ZMQInterface_thunk_glnxa64.c: At top level:
ZMQInterface_thunk_glnxa64.c:42:30: error: expected declaration specifiers or ‘...’ before string constant
EXPORT_EXTERN_C (visibility("default")))void*create_socket_context(voidThunk(void fcn(),const char *callstack,int stacksize)
^
Try 2 :
Then I tried removing the __attribute__ ((visibility ("default"))) then compiled and loaded. But I am getting following error then
Error using loadlibrary
There was an error loading the library "/home/varun/zmqproj/ZMQInterface.so"
Missing symbol 'zmq_connect' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_ctx_new' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_recv' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_send' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_socket' required by '/home/varun/zmqproj/ZMQInterface.so'
Caused by:
Error using loaddefinedlibrary
Missing symbol 'zmq_connect' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_ctx_new' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_recv' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_send' required by '/home/varun/zmqproj/ZMQInterface.so'
Missing symbol 'zmq_socket' required by '/home/varun/zmqproj/ZMQInterface.so'
Could any one help me to know the actual cause for this issue ?
Execution Environment :
OS - CentOS 7 64 bit
gcc version - gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
MATLAB 2017a

回答 (0 件)

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by