473,509 Members | 3,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

having main in shared library

I have created a shared library with main() .Still it is compiled and
loaded during invocation. Below is the code and build file.

sample_test.cpp
int test_method(CfgChkSession &s)
{
cout<<"working"<<endl;
return 1;
}

int main()
{
cout << "Hello, This is a sample test\n";
return 0;

}
Sample build file is :
all:libcfgchk_samplelib.so

libcfgchk_samplelib.so : $(OBJS)
$(GCC) -shared -Wl,-soname,libcfgchk_samplelib.so -o
libcfgchk_samplelib.so $(OBJS) - -lutil -lext_stl -lprocess -lnsl -
lcfgchk_utils -ldl

I am curious to know how the .so in invoked in the program which has a
main(). Please update me on the same

Oct 19 '07 #1
1 2657
On Oct 19, 6:04 am, athr...@gmail.com wrote:
I have created a shared library with main() .Still it is compiled and
loaded during invocation. Below is the code and build file.

sample_test.cpp
int test_method(CfgChkSession &s)
{
cout<<"working"<<endl;
return 1;

}

int main()
{
cout << "Hello, This is a sample test\n";
return 0;

}

Sample build file is :
all:libcfgchk_samplelib.so

libcfgchk_samplelib.so : $(OBJS)
$(GCC) -shared -Wl,-soname,libcfgchk_samplelib.so -o
libcfgchk_samplelib.so $(OBJS) - -lutil -lext_stl -lprocess -lnsl -
lcfgchk_utils -ldl

I am curious to know how the .so in invoked in the program which has a
main(). Please update me on the same
I believe that in the .so main is a "weak symbol" which prevents the
multiply defined symbol error you are expecting. The global symbol
main is chosen preferentially over the weak symbol main in the shared
object.
http://www.tortall.net/projects/yasm...t-elf-dir-weak

YT,
Dan Noland
http://nolandda.org/

Oct 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2172
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
0
2259
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
1
4400
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared...
2
2015
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
5
3983
by: Ivan | last post by:
I am used to VB6 and am not sure how to do this in Vstudio .NET. I have a main form which calls other forms. I want to disable that main form while other ones are called. I tried hiding it and...
4
1519
by: Bob Day | last post by:
Using VS 2003, VB.net , MSDE .... I am confused by the help example below. In a sub main (whether in a module or winform), do you have to explicitly start the Main_Thread, as they do in this...
3
7826
by: Shawnk | last post by:
I use two classes to manage the Main() command line (and alot of other stuff) for my prototyping environment. I tryed putting the MainClass in a DLL and just having the other class (which gets...
14
1655
by: Sumit77Sen | last post by:
who calls main() ?
2
2158
by: blackbiscuit | last post by:
Dear All, Now in my current developing project, I have defined a global object in the main program . In dlls, there are also some static object whose constructor will use the global object in...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.