How to make executable shared libraries?
Frank Chang
frankchang91 at gmail.com
Sat Jan 2 13:09:41 UTC 2016
Yesterday, I read the web blog article
http://rachid.koucha.free.fr/tech_corner/executable_lib.html, How to
make executable shared libraries . In this article it states that if
one types at a Linux command prompt: $ gcc -shared service.c -o
libservice.so -Wl,-soname,libservice.so -W1,-e lib_entry followed by $
./libservice.so, then we can directly executer the lib_entry function.
However, when I run a similar g++ command: $ g++ -shared one.cpp
two.cpp three.cpp -o libservice.so -Wl,-soname,libservice.so -W1,-e
lib_entry , where lib_entry is a C function defined in two.cpp I get
the warning message: No entry point lib_entry point found. How do I
fix this warning message so I can directly run the entry point,
lib_entry?
I tried extern "C" linkage with lib_entry as you recommended:
extern "C" { void lib_entry(void) { ... } }
and compiled with: g++ -shared -fPIC -DLINUX -I
/home/venkat/Downloads/waitForMultipleObjects -I
/home/venkat/developmentMono/SmartCamXi_Hybrid/Include -efunc
DataServer.cpp DataServerLib.cpp DataTransferClient.cpp
CWinEventHandle.cpp WinEvent.cpp -lpthread -lrt -o myprogBC.so Then I
ran this ; $ ./myprogBC.so.
Then I got the error message: which means that I am on a 64 bit
system trying to make a 32 bit library.
When I try: g++ -m32, I get : bits/c++config.h: No such
file/directory : How do I fix this?
Then i read this URL,
stackoverflow.com/questions/4643197/missing-include-bits-cconfig-h-when-cross-compiling-64-bit-program-on-32-bit?lq=1
which said to: sudo apt-get install gcc-4.9-multilib g++-4.9-multilib
which I did and got the following error message;
$ sudo apt-get install gcc-4.9-multilib g++-4.9-multilib
[sudo] password for vendor:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-4.9-multilib
E: Couldn't find any package by regex 'gcc-4.9-multilib'
E: Unable to locate package g++-4.9-multilib
E: Couldn't find any package by regex 'g++-4.9-multilib'
Please advise me how to fix this error on Ubuntu Linux 14.10 LTS. I
would iike to avoid upgrading to Ubuntu 15.10 but will do so if
absolutely necessary,.
sudo apt-get install gcc-4.9-multilib g++-4.9-multilib
Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20160102/d4384fe8/attachment.html>
More information about the ubuntu-users
mailing list